#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; int sum=0; int dividend; vector<int> dividers; cin>> n; for(int i=1; i*i<=n; i++) { if(n%i==0) { dividers.push_back(i); if(n/i!=i&&n/i<=n/7) dividers.push_back(n/i); } } for(int i=0; i<dividers.size(); i++){ dividend=n/dividers[i]-1; for(int j=2; j*j<=dividend; j++) { if(dividend%j==0){ if(((dividend/j)-1)>1){ sum++; if(dividend/j!=j){ if(j-1>1){ sum++; } } } } } } cout << sum; 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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; int sum=0; int dividend; vector<int> dividers; cin>> n; for(int i=1; i*i<=n; i++) { if(n%i==0) { dividers.push_back(i); if(n/i!=i&&n/i<=n/7) dividers.push_back(n/i); } } for(int i=0; i<dividers.size(); i++){ dividend=n/dividers[i]-1; for(int j=2; j*j<=dividend; j++) { if(dividend%j==0){ if(((dividend/j)-1)>1){ sum++; if(dividend/j!=j){ if(j-1>1){ sum++; } } } } } } cout << sum; return 0; } |