#include <iostream> #include <vector> using namespace std; long long calc(const int n) { long long result = 0; for(long long i = 1; i < n; ++i) { if(n%i != 0) continue; for(long long j = 2; j < n; ++j) { long long sum = i + i*j; if(sum > n) break; long long rem = n - sum; if(rem > i*j && rem%i == 0 && rem%(i*j) == 0) ++result; } } return result; } int main() { int n; cin >> n; cout << calc(n) << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <iostream> #include <vector> using namespace std; long long calc(const int n) { long long result = 0; for(long long i = 1; i < n; ++i) { if(n%i != 0) continue; for(long long j = 2; j < n; ++j) { long long sum = i + i*j; if(sum > n) break; long long rem = n - sum; if(rem > i*j && rem%i == 0 && rem%(i*j) == 0) ++result; } } return result; } int main() { int n; cin >> n; cout << calc(n) << endl; } |