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;
}

 

posted @ 2016-01-25 17:08  Fighting_Heart  阅读(152)  评论(0编辑  收藏  举报