【POJ2196】Specialized Four-Digit Numbers(暴力打表)

一道水题,只要会复制粘贴就好!

 

 1 #include <iostream>

 2 #include <cstring>

 3 #include <cstdlib>

 4 #include <numeric>

 5 #include <cstdio>

 6 #include <algorithm>

 7 #include <cctype>

 8 #include <cmath>

 9 #include <climits>

10 #include <vector>

11 

12 #define PI acos(-1)

13 using namespace std;

14 

15 int Judge_Ten (int i) {

16     int res = 0;

17     while (i) {

18         res += i % 10;

19         i /= 10;

20     }

21     return res;

22 }

23 

24 int Judge_Hex (int i) {

25     int res = 0;

26     while (i) {

27         res += i % 16;

28         i /= 16;

29     }

30     return res;

31 }

32 

33 int Judge_Twe (int i) {

34     int res = 0;

35     while (i) {

36         res += i % 12;

37         i /= 12;

38     }

39     return res;

40 }

41 

42 bool Judge (int i) {

43     if (Judge_Hex(i) == Judge_Twe(i) && Judge_Ten(i) == Judge_Twe(i)) {

44         return true;

45     }

46     return false;

47 }

48 

49 int main () {

50     //cout << Judge_Ten (2992) << endl;

51     //cout << Judge_Twe (2992) << endl;

52     //cout << Judge_Hex (2992) << endl;

53     //freopen ("out.txt", "w", stdout);

54     for (int i = 2992; i < 10000; ++ i) {

55         if (Judge (i)) {

56             cout << i << endl;

57         } else {

58             continue;

59         }

60     }

61     return 0;

62 }

 

你可能感兴趣的:(number)