HDOJ1014 Uniform Generator

简介:

依题意可知,只要两个数的最大公约数为1就ok了~

复制代码
 1 #include <stdio.h>
 2 int gcd(int a,int b)
 3 {
 4     int t,min,max;
 5     min=a<b?a:b;
 6     max=a<b?b:a;
 7     while (t=max%min,t!=0)
 8     {    
 9         max=min;
10         min=t;
11     }
12     return min;
13 }
14 int main()
15 {
16     int a,b,g;
17     while (~scanf("%d%d",&a,&b))
18     {
19         g=gcd(a,b);
20         printf("%10d%10d    ",a,b);
21         if(g>1)
22             printf("Bad Choice\n\n");
23         else
24             printf("Good Choice\n\n");
25     }
26     return 0;
27 }
复制代码

 


本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2013/03/12/2955332.html,如需转载请自行联系原作者

相关文章
|
1月前
|
TensorFlow 算法框架/工具
【Tensorflow】解决A `Concatenate` layer should be called on a list of at least 2 inputs
在TensorFlow 2.0中,使用Concatenate函数时出现错误,可以通过替换为tf.concat 来解决。
21 4
|
1月前
|
PyTorch 算法框架/工具
【Pytorch】解决Fan in and fan out can not be computed for tensor with fewer than 2 dimensions
本文提供了两种解决PyTorch中由于torchtext版本问题导致的“Fan in and fan out can not be computed for tensor with fewer than 2 dimensions”错误的方法。
55 2
HDOJ 1014 Uniform Generator(公约数问题)
HDOJ 1014 Uniform Generator(公约数问题)
84 0
HDOJ 1095 A+B for Input-Output Practice (VII)
HDOJ 1095 A+B for Input-Output Practice (VII)
98 0
|
IDE Linux 编译器
hostguest nativelangsys及uniform cui cross compile system
本文关键字:windows host targetting at linux,Compile for linux on windows using mingw64,Cross-compiling on Windows for Linux
194 0
hostguest nativelangsys及uniform cui cross compile system
|
机器学习/深度学习 算法框架/工具 Caffe
【caffe】loss function、cost function和error
@tags: caffe 机器学习 在机器学习(暂时限定有监督学习)中,常见的算法大都可以划分为两个部分来理解它 一个是它的Hypothesis function,也就是你用一个函数f,来拟合任意一个输入x,让预测值t(t=f(x))来拟合真实值y 另一个是它的cost function,也就是你用一个函数E,来表示样本总体的误差。
1336 0