#include <iostream> unsigned int perms(const unsigned int n) { unsigned int p = 0; for (unsigned int a = 1; a <= n / 7; ++a) { if (n % a == 0) { for (unsigned int b = 2 * a; 3 * b <= n - a; b += a) { if ((n - a - b) % b == 0) ++p; } } } return p; } int main() { unsigned int n; std::cin >> n; std::cout << perms(n) << std::endl; 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 | #include <iostream> unsigned int perms(const unsigned int n) { unsigned int p = 0; for (unsigned int a = 1; a <= n / 7; ++a) { if (n % a == 0) { for (unsigned int b = 2 * a; 3 * b <= n - a; b += a) { if ((n - a - b) % b == 0) ++p; } } } return p; } int main() { unsigned int n; std::cin >> n; std::cout << perms(n) << std::endl; return 0; } |