HDU 5610 Baby Ming and Weight lifting
暴力枚举
#include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<list> #include<algorithm> using namespace std; int T,a,b,C; int main() { scanf("%d",&T); while(T--) { scanf("%d%d%d",&a,&b,&C); int num1=99999,num2=99999; int MinNum=0x7fffffff; for(int i=0;;i=i+2) { if(a*i>C) break; for(int j=0;;j=j+2) { if(a*i+b*j>C) break; if(a*i+b*j==C) { if(i+j<num1+num2) { num1=i; num2=j; } } } } if(num1==99999&&num2==99999) printf("Impossible\n"); else printf("%d %d\n",num1,num2); } return 0; }