Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1562
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 Input244 38 4925 56 3
Sample OutputImpossible2575
Author8600
1#include <stdio.h>2#include <iostream>3 using namespacestd;4 intMain ()5 {6 intT;7 inta,b,c,x;8 BOOLFlag1,flag2,flag3;9Cin>>T;Ten while(t--) One { ACin>>a>>b>>C; -flag1=false; flag2=false; flag3=false; - for(x= +; x<=9999; x + +)//preprocessing prevents timeouts the { - if(x%a==0) - { -flag1=true; + Break; - } + } A if(FLAG1) at { - for(; x<=9999; x+=a) - { - if((x+1)%b==0&& (x+2)%c==0) - { -Flag2=true; incout<<x<<Endl; - Break; to } + } - } the if(!Flag2) *cout<<"Impossible"<<Endl; $ }Panax Notoginseng return 0; -}
HDU 1562 Guess the number