#include<iostream> #include<stdio.h> #include<list> #include<cmath> using namespace std; list<int> dzielniki; int n = 0; int resault = 0; list<int> FindDzielniki(int number, int starting) { list<int> resault = {}; int max = number / 2; for (int i = starting; i <= number && i <= max; i++) { if (number % i == 0) { resault.push_back(i); //number /= i; } } return resault; } int main() { cin >> n; list<int> a = FindDzielniki(n, 1); for (list<int>::iterator it = a.begin(); it != a.end(); it++) { int tempNumber = (n / (*it)) - 1; list<int> b = FindDzielniki(tempNumber, 2); if (b.size() == 0) continue; list<int>::iterator iter = b.end(); iter--; if (*(iter) == tempNumber / 2) resault--; resault += b.size(); } cout << resault << "\n"; }
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 | #include<iostream> #include<stdio.h> #include<list> #include<cmath> using namespace std; list<int> dzielniki; int n = 0; int resault = 0; list<int> FindDzielniki(int number, int starting) { list<int> resault = {}; int max = number / 2; for (int i = starting; i <= number && i <= max; i++) { if (number % i == 0) { resault.push_back(i); //number /= i; } } return resault; } int main() { cin >> n; list<int> a = FindDzielniki(n, 1); for (list<int>::iterator it = a.begin(); it != a.end(); it++) { int tempNumber = (n / (*it)) - 1; list<int> b = FindDzielniki(tempNumber, 2); if (b.size() == 0) continue; list<int>::iterator iter = b.end(); iter--; if (*(iter) == tempNumber / 2) resault--; resault += b.size(); } cout << resault << "\n"; } |