首页 > 代码库 > 【POJ2196】Specialized Four-Digit Numbers(暴力打表)
【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 }
【POJ2196】Specialized Four-Digit Numbers(暴力打表)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。