标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 178 Accepted Submission(s): 77
#include<iostream> #include<cstdio> #define LL __int64 using namespace std; int t; int a,b,c; int flag; int tt,ansa,ansb; int main() { while(scanf("%d",&tt)!=EOF) { for(int i=1; i<=tt; i++) { flag=0; scanf("%d%d%d",&a,&b,&c); if(c%2) printf("Impossible\n"); else { if(a<b) { t=a; a=b; b=t; flag=1; } int gg=0; for(int j=0; j<=c/2/a; j++) for(int k=0; k<=c/2/b; k++) { if(j*a+k*b==c/2) { ansa=j; ansb=k; gg=1; break; } } if(gg==0) printf("Impossible\n"); else { if(flag) printf("%d %d\n",2*ansb,2*ansa); else printf("%d %d\n",2*ansa,2*ansb); } } } } return 0; }
标签:
原文地址:http://www.cnblogs.com/hsd-/p/5154333.html