标签:
1 #include<cstdio> 2 #include<cmath> 3 #include<cstring> 4 #include<iostream> 5 using namespace std; 6 int n,a,b,c; 7 bool bo,bo1; 8 int main(){ 9 scanf("%d",&n); 10 while(n--) 11 { 12 bo=false; 13 bo1=false; 14 scanf("%d %d %d",&a,&b,&c); 15 if (c%2!=0) 16 printf("Impossible\n"); 17 else 18 { 19 c=c/2; 20 if (a>b) 21 { 22 swap(a,b); 23 bo1=true; 24 } 25 for(int i=1000;i>=0;--i) 26 { 27 for(int j=1000;j>=0;--j) 28 { 29 if (b*i+a*j==c&&bo1==true) 30 { 31 printf("%d %d\n",2*i,2*j); 32 bo=true; 33 break; 34 }else if(b*i+a*j==c){ 35 36 printf("%d %d\n",2*j,2*i); 37 bo=true; 38 break; 39 } 40 } 41 if (bo==true) 42 break; 43 } 44 if (bo!=true) 45 printf("Impossible\n"); 46 } 47 } 48 return 0; 49 }
HDU 5610 Baby Ming and Weight lifting 暴力
标签:
原文地址:http://www.cnblogs.com/fakerv587/p/5179738.html