Guess the number
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3035 Accepted Submission (s): 2281
Problem Descriptionhappy New Year to everybody!
Now, I want your to guess a minimum number x BETWWN and 9999
(1) x% A = 0;
(2) (x+1)% B = 0;
(3) (x+2)% c = 0;
And A, B, c are integers between 1 and 100.
Given A,b,c, tell me what's the number of x?
Inputthe Number of test cases C is in the first line of input, then C test Cases Followed.every test contains three intege Rs A, B, C.
Outputfor each test case your program should output one and the minimal number x, you should remember that X is BETW Een and 9999. If There is no answer for X, Output "impossible".
Sample Input
244 38 4925) 56 3
Sample Output
Impossible2575
Author8600
Sourcehappy 2007 It's a waste of time doing the subject.
#include <iostream>using namespace Std;int main () {int N,a,b,c,i;cin>>n;while (n--) {cin>>a>>b >>c;for (i=1000;i<=9999;i++) if ((i%a==0) && ((i+1)%b==0) && ((i+2)%c==0)) {cout<<i< <endl;; break;} if (i>9999) cout<< "impossible" <<ENDL;} return 0;}
Hangzhou Electric HDU ACM 1562 Guess the number