hdu 2504】的更多相关文章

又见GCD Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 18480    Accepted Submission(s): 7708 Problem Description 有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b.若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c.   Input 第一行输入一…
Problem Description 有三个正整数a,b,c(0 import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc= new Scanner(System.in); int t =sc.nextInt(); while(t-->0){ int a =sc.nextInt(); int b =sc.nextInt(); int c=0; for(int…
Problem Description 有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b.若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c. Input 第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b. Output 输出对应的c,每组测试数据占一行. Sample Input 2 6 2 12 4 Sample Output 4 8 一道水题!!!! 代码: #include <iostream> using names…
又见GCD Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10031    Accepted Submission(s): 4185 Problem Description 有三个正整数a,b,c(0<a,b,c<10^6),当中c不等于b.若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c.   Input 第一行输入一…
题意:是中文题. 析:a和c的最大公因数是b,也就是说,a和c除了b就没有公因数了.再说就是互质了. 所以先把a除以b,然后一个暴力n,满足gcd(a, n) =1,就结束,就是n倍的c. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <cstring> #incl…
又见GCD Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19327    Accepted Submission(s): 8044 Problem Description 有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b.若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c.   Input 第一行输入一个…
又见GCD Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19497    Accepted Submission(s): 8129 Problem Description 有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b.若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c.   Input 第一行输入一个…
这个题真的很水,但我竟然连错,在此警醒自己!!! 写代码改了东边,忘了西边,“认真”这两个字又被我吃了,打脸啪啪啪啪. #include<iostream> using namespace std; int gcd(int a, int b) { int t; while(b) { t = a; a = b; b = t%b; } return a; } int main() { int T; cin>>T; while(T--) { long long a, b; cin>…
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201…
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093.1094.1095.1096.1097.1098.1106.1108.1157…