试题D 数的分解
作者:互联网
答案:40785
#include <iostream> using namespace std; bool check(int i) { int x; while (i) { x = i % 10; if (x == 2 || x == 4) return false; i /= 10; } return true; } /* 条件约束: 1.各整数不相等 2.每个整数不含2或4 3.不能有重复的(j=j+1;k=k+1避免不重复) */ int main() { int n = 2019, count = 0, k; for (int i = 1; i < 2000; i++) { if (check(i)) { for (int j = i + 1; j < 2000; j++) { if (check(j) && j != i) { for (int k = j + 1; k < 2000; k++) { if (check(k) && k != i && k != j && i + j + k == 2019) { count++; } } } } } } cout << count; return 0; }
标签:试题,int,++,2000,分解,2019,&&,check 来源: https://www.cnblogs.com/lxpblogs/p/16035601.html