poj 2196(水题)
作者:互联网
#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; }
标签:水题,int,s2,s1,s3,while,poj,2196,p% 来源: https://www.cnblogs.com/stevenzrx/p/15083490.html