标签:
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1562
1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 int main() 5 { 6 int T; 7 int a,b,c,x; 8 bool flag1,flag2,flag3; 9 cin>>T; 10 while(T--) 11 { 12 cin>>a>>b>>c; 13 flag1=false;flag2=false;flag3=false; 14 for(x=1000;x<=9999;x++)//预处理防止超时 15 { 16 if(x%a==0) 17 { 18 flag1=true; 19 break; 20 } 21 } 22 if(flag1) 23 { 24 for(;x<=9999;x+=a) 25 { 26 if((x+1)%b==0&&(x+2)%c==0) 27 { 28 flag2=true; 29 cout<<x<<endl; 30 break; 31 } 32 } 33 } 34 if(!flag2) 35 cout<<"Impossible"<<endl; 36 } 37 return 0; 38 }
标签:
原文地址:http://www.cnblogs.com/Annetree/p/5735258.html