// Grzegorz Bukowiec // Potyczki Algorytmiczne 2018 // Runda probna - PIN #include <iostream> #include <cmath> using namespace std; int resolve2(int sum) { int result = 0; int limit = sqrt(sum); for (int b = 2; b <= limit; ++b) { if (sum % b == 0) { if (b <= sum / 3) { ++result; } if (b * b < sum && sum / b <= sum / 3) { ++result; } } } return result; } int resolve3(int sum) { int result = 0; int limit = sqrt(sum); for (int a = 1; a <= limit; ++a) { if (sum % a == 0) { if (a <= sum / 7) { result += resolve2(sum / a - 1); } if (a * a < sum && sum / a <= sum / 7) { result += resolve2(a - 1); } } } return result; } int main() { int sum; cin >> sum; cout << resolve3(sum) << 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | // Grzegorz Bukowiec // Potyczki Algorytmiczne 2018 // Runda probna - PIN #include <iostream> #include <cmath> using namespace std; int resolve2(int sum) { int result = 0; int limit = sqrt(sum); for (int b = 2; b <= limit; ++b) { if (sum % b == 0) { if (b <= sum / 3) { ++result; } if (b * b < sum && sum / b <= sum / 3) { ++result; } } } return result; } int resolve3(int sum) { int result = 0; int limit = sqrt(sum); for (int a = 1; a <= limit; ++a) { if (sum % a == 0) { if (a <= sum / 7) { result += resolve2(sum / a - 1); } if (a * a < sum && sum / a <= sum / 7) { result += resolve2(a - 1); } } } return result; } int main() { int sum; cin >> sum; cout << resolve3(sum) << std::endl; return 0; } |