http://acm.sdibt.edu.cn/JudgeOnline/problem.php?id=1184

此题给我们一个数的千、百、十位,要求我们求其万位和个位数值

#include<stdio.h>
int main(){
    int t;
    while(scanf("%d",&t)!=EOF){
        int n,x,z,y;
        while(t--){
            scanf("%d%d%d%d",&n,&x,&y,&z);
            int i,j,sum,flag=0;
            for(i=9;i>=1;i--){
                for(j=9;j>=0;j--){
                    sum=10000*i+1000*x+100*y+10*z+j;
                    if(sum%n==0){
                        printf("%d %d %d\n",i,j,sum/n);
                        flag=1;
                        break;
                    }
                }
                if(flag)
                    break;
            }
            if(!flag)
                puts("0");
        }
    }
    return 0;
}

发表评论

电子邮件地址不会被公开。

Post Navigation