//#include "/Users/dimazhylko/CPPProjects/bits/stdc++.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; int res=0; for(int a = 2;a*a<=n;a++){ if(n%a==0 && a*a!=n){ int r = n/a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } r = a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } } else if(a*a==n){ int r = n/a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } } } n--; for(int i = 2;i*i<=n;i++){ if(n%i==0){ if(n-i > i)res++; if(n - n/i != n-i && n - n/i > n/i)res++; } } cout<<res<<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 48 49 50 51 52 53 54 55 | //#include "/Users/dimazhylko/CPPProjects/bits/stdc++.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; int res=0; for(int a = 2;a*a<=n;a++){ if(n%a==0 && a*a!=n){ int r = n/a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } r = a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } } else if(a*a==n){ int r = n/a - 1; for(int b = 2;b*b<=r;b++){ if(r%b==0){ if(r-b > b)res++; if(r - r/b != r-b && r - r/b > r/b)res++; } } } } n--; for(int i = 2;i*i<=n;i++){ if(n%i==0){ if(n-i > i)res++; if(n - n/i != n-i && n - n/i > n/i)res++; } } cout<<res<<endl; return 0; } |