#include <iostream> #include <vector> using namespace std; typedef vector<int> divisior; divisior GetDivisiors(int n) { divisior rV; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { rV.push_back(i); if (n / i != i) rV.push_back(n/i); } } return rV; } int main() { int n; cin >> n; int count = 0; divisior aCandidats = GetDivisiors(n); for(int i = 0; i< aCandidats.size();i++) { int a = aCandidats[i]; divisior possible_x = GetDivisiors(n/a -1 ); for (int j = 0; j< possible_x.size(); j++) { int x = possible_x[j]; int b = a * x; if (a >= b) continue; int c = n - a - b; if (c % b == 0 && c > b) count++; } } cout << count; 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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <iostream> #include <vector> using namespace std; typedef vector<int> divisior; divisior GetDivisiors(int n) { divisior rV; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { rV.push_back(i); if (n / i != i) rV.push_back(n/i); } } return rV; } int main() { int n; cin >> n; int count = 0; divisior aCandidats = GetDivisiors(n); for(int i = 0; i< aCandidats.size();i++) { int a = aCandidats[i]; divisior possible_x = GetDivisiors(n/a -1 ); for (int j = 0; j< possible_x.size(); j++) { int x = possible_x[j]; int b = a * x; if (a >= b) continue; int c = n - a - b; if (c % b == 0 && c > b) count++; } } cout << count; return 0; } |