2484 - H
时间限制 : 1 秒
内存限制 : 128 MB
给你一个nm的棋盘,求最长的一根对角线穿过了多少个11的小正方形。
题目输入
多组数据,每组输入n,m (n,m<10^18)
题目输出
输出方案数
输入/输出样例
输入格式
1 5 2 2 4 4 8 4
输出格式
5 2 4 8
C++解答
#include <cstdio> #include <iostream> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; LL gcd(LL a,LL b){ if(b==0) return a; return gcd(b,a%b); } int main(){ LL a,b; //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while(scanf("%lld%lld",&a,&b)!=EOF){ printf("%lld\n",a+b-gcd(a,b)); } return 0; }