http://acm.hdu.edu.cn/showproblem.php?pid=1562
找出(1) x % a = 0;,然后用a作为递增的量,x为初始量

View Code
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,t,c,x,i; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d%d%d",&a,&b,&c); 9 for(x=1000;;x++) 10 if(x%a==0) 11 break; 12 for(;x<10000;x+=a) 13 { 14 if((x+1)%b==0&&(x+2)%c==0) 15 { 16 printf("%d\n",x); 17 break; 18 } 19 } 20 if(x>=10000) 21 printf("Impossible\n"); 22 } 23 return 0; 24 }
本文提供了一种解决HDU 1562编程题的方法,使用C语言实现,通过循环和条件判断找到满足特定数学条件的最小正整数x。题目要求x对a取模为0,且x+1对b取模为0,x+2对c取模为0,若找不到这样的x则输出Impossible。
894

被折叠的 条评论
为什么被折叠?



