#include<bits/stdc++.h> using namespace std; int32_t main(){ ios::sync_with_stdio(false); int n; cin >> n; vector<int> divs; divs.reserve(1e5); for(int j=1;j*j<=n;j++){ if(n % j == 0){ divs.push_back(j); if(n/j != j) divs.push_back(n/j); } } int res=0; for(int i=0;i<divs.size();i++){ int a = divs[i]; int b = n/divs[i]-1; if(b <= 1) continue; for(int j=1;j*j<=b;j++){ if(b % j == 0){ if(b/j >= 3 && j >= 2){ res++; } if(b/j != j && b/j >= 2 && j >= 3) res++; } } } cout<<res<<"\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 | #include<bits/stdc++.h> using namespace std; int32_t main(){ ios::sync_with_stdio(false); int n; cin >> n; vector<int> divs; divs.reserve(1e5); for(int j=1;j*j<=n;j++){ if(n % j == 0){ divs.push_back(j); if(n/j != j) divs.push_back(n/j); } } int res=0; for(int i=0;i<divs.size();i++){ int a = divs[i]; int b = n/divs[i]-1; if(b <= 1) continue; for(int j=1;j*j<=b;j++){ if(b % j == 0){ if(b/j >= 3 && j >= 2){ res++; } if(b/j != j && b/j >= 2 && j >= 3) res++; } } } cout<<res<<"\n"; } |