(HDU)1197 -- Specialized Four-Digit Numbers(特殊四位数)

题目链接:http://vjudge.net/problem/HDU-1197

找四位数中10进制、12进制、16进制表示各位数字和相同的数值。枚举即可:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8 
 9 using namespace std;
10 
11 
12 int main()
13 {
14     int i,ans10,ans12,ans16,temp1,temp2,temp3;
15     for(i=2992;i<=9999;i++)
16     {
17         temp1=i;    temp2=i;    temp3=i;
18         ans10=0;    ans12=0;    ans16=0;
19         while(temp1)
20         {
21             ans10+=temp1%10;
22             temp1/=10;
23         }
24         while(temp2)
25         {
26             ans12+=temp2%12;
27             temp2/=12;
28         }
29         while(temp3)
30         {
31             ans16+=temp3%16;
32             temp3/=16;
33         }
34         if(ans10==ans12&&ans12==ans16)
35             printf("%d
",i);
36     }
37     return 0;
38 }
原文地址:https://www.cnblogs.com/ACDoge/p/6133030.html