标签:
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=2534
Hint:
题意:
中文。
题解:
本题有计算的公式,当gcd=1的时候,答案为n*m-n-m。其他的情况下就为inf。
代码:
#include <cstdio> typedef long long ll; ll gcd(ll a,ll b) { if(a%b==0) return b; else return gcd(b,a%b); } int main() { ll n,m; while(scanf("%lld%lld",&n,&m)!=EOF&&n!=0&&m!=0) { if(gcd(n,m)==1) printf("%lld\n",n*m-n-m); else printf("Inf\n"); } }
标签:
原文地址:http://www.cnblogs.com/TAT1122/p/5877006.html