首页 > 其他 > 详细

poj 2196(水题)

时间:2021-07-31 11:20:45      阅读:21      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<cstdio>
using namespace std;
bool test(int n){
    int p,s1,s2,s3;
    s1 = s2 = s3 = 0;
    p = n;
    while(p>0){
        s1 += p%10;
        p /= 10;
    }
    p = n;
    while(p>0){
        s2 += p%12;
        p /= 12;
    } 
    p = n;
    while(p>0){
        s3 += p%16;
        p/= 16;
    }
    if(s1==s2&&s2==s3)return true;
    return false;
}
int main(){
    int ans[10000],n = 0;
    for(int i=2992;i<10000;i++){
        if(test(i))ans[n++] = i;
    }
    for(int i=0;i<n;i++){
        printf("%d\n",ans[i]); 
    }
    return 0;
}

 

poj 2196(水题)

原文:https://www.cnblogs.com/stevenzrx/p/15083490.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!