Problem : 2504 ( 又见GCD ) Judge Status : AcceptedRunId : 5973980 Language : C++ Author : qq1203456195Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
1 #include <cstdio>
2 using namespace std;
3 int gcd(
int a,
int c)
4 {
5 int t;
6 if(c<a) {t=a;a=c;c=
t;}
7 while (t=c%a,t!=
0)
8 {
9 c=
a;
10 a=
t;
11 }
12 return a;
13 }
14 int main()
15 {
16 int a,b,c,cas;
17 scanf(
"%d",&
cas);
18 while (cas--
)
19 {
20 scanf(
"%d %d",&a,&b);
//c一定是b的倍数
21 c=b<<
1;
22 while(b!=
gcd(a,c))
23 c+=
b;
24 printf(
"%d\n",c);
25 }
26 return 0;
27 }
转载于:https://www.cnblogs.com/CheeseZH/archive/2012/05/20/2510916.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1494484.html