2196Specialized Four-Digit Numbers

真的是水题一道啊,看懂题意就好了,这是人家的代码....自己懒得做啊,不过看完之后才知道其实应该动下手的....嘻嘻

#include<stdio.h>
const int Base10[]={1000,100,10,1};
const int Base12[]={1728,144,12,1};
const int Base16[]={4096,256,16,1};
int main(void)
{
    int Sum10,Sum12,Sum16,i,j,tmp10,tmp12,tmp16;
    for(i=2992;i<10000;i++)
    {
        Sum10=Sum12=Sum16=0;
        tmp10=tmp12=tmp16=i;
        for(j=0;j<4;++j)
        {
            Sum10+=tmp10/Base10[j];
            tmp10%=Base10[j];
            Sum12+=tmp12/Base12[j];
            tmp12%=Base12[j];
            Sum16+=tmp16/Base16[j];
            tmp16%=Base16[j];
        }
        if(Sum10==Sum12&&Sum10==Sum16) 
        printf("%d\n",i);
    }
    return 0;
}

 

 

posted @ 2013-09-19 15:50  龙城星  阅读(109)  评论(0编辑  收藏  举报