#include <cstdlib> #include <iostream> using namespace std; static void getPin(long n) { int numOfComb = 0; int maxA = n / 6; for (long a = 1; a <= maxA; a++) { if ((n-a) % a != 0) continue; for (long ii = 2; ((a + 3*a*ii) <= n); ii++) { long b = a * ii; long c = (n - b - a); if ((c % b == 0) && (c % a) == 0) { numOfComb++; } } } cout << numOfComb; } int main(int argc, char** argv) { int n = 0; cin >> n; getPin(n); 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 | #include <cstdlib> #include <iostream> using namespace std; static void getPin(long n) { int numOfComb = 0; int maxA = n / 6; for (long a = 1; a <= maxA; a++) { if ((n-a) % a != 0) continue; for (long ii = 2; ((a + 3*a*ii) <= n); ii++) { long b = a * ii; long c = (n - b - a); if ((c % b == 0) && (c % a) == 0) { numOfComb++; } } } cout << numOfComb; } int main(int argc, char** argv) { int n = 0; cin >> n; getPin(n); return 0; } |