SDNU 1254.Problem B. SOS(水题)

mac2022-06-30  19

Description

Lulichuan is a good captain, He is thinking every day how to make his team stronger,However, his team members always disappointed him.They always make mistakes, like WA, TLE, MLE, CE,PE.....Today, he thought of a good way to make team members stronger. That is to make the peoblem simpler. So he got a easy problem, now, we have three numbers, a, b, c,

We know gcd(a,c) = b,  but, we lose the c, we only know a, b, b != c,we want to know the smallest c.

(0 < a, b, c< 10000000)

Input

 T(0 < T <= 10000) T is TestCase

 a, b(0 < a, b<=10000000)

Output

 Case #TestCase: answer

Sample Input

2 6 2 12 4

Sample Output

Case #1: 4 Case #2: 8

Source

Unknown #include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long int t, a, b, c; int gcd(int a, int b) { if(a%b == 0)return b; return gcd(b, a%b); } int main() { scanf("%d", &t); int miao = t; while(t--) { scanf("%d%d", &a, &b); c = b*2; while(gcd(a, c) != b)c += b; printf("Case #%d: %d\n", miao-t, c); } return 0; }

 

转载于:https://www.cnblogs.com/RootVount/p/10993078.html

最新回复(0)