#include <iostream> using namespace std; int main(){ int n; cin >> n; int res = 0; for(int a = 1; a < n/4; a++){ for(int b = a * 2; b < n/2;){ for(int c = b * 2; c < n; c*=b) if(a+b+c == n) res++; if(a == 1) b*=2; else b*=a; } } cout << res; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> using namespace std; int main(){ int n; cin >> n; int res = 0; for(int a = 1; a < n/4; a++){ for(int b = a * 2; b < n/2;){ for(int c = b * 2; c < n; c*=b) if(a+b+c == n) res++; if(a == 1) b*=2; else b*=a; } } cout << res; return 0; } |