(HDU)1562-- Guess the number (猜数字)

题目链接:https://vjudge.net/problem/HDU-1562

我稍微加了点剪枝,但是水题似乎没有必要。

    #include 
    #include 
    #include 
    #include 
    #include 
    #include <string>
    #include 

    using namespace std;

    int main()
    {
        #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
        freopen("test.out","w",stdout);
        #endif // ONLINE_JUDGE

        int t,a,b,c,i,ans;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d %d %d",&a,&b,&c);
            int left=1000,right=9999,flag=0;
            for(i=left;i<=right;i++)
            {
                if(i%a!=0) continue;
                if((i+1)%b!=0) continue;
                if((i+2)%c!=0) continue;
                flag=1;
                ans=i;
                break;
            }
            if(flag) printf("%d\n",ans);
            else printf("Impossible\n");
        }
        return 0;
    }

 

转载于:https://www.cnblogs.com/ACDoge/p/6141624.html

你可能感兴趣的:((HDU)1562-- Guess the number (猜数字))