#include <iostream> using namespace std; int divisors(int n); int divisors(int n) { if (n<6) return 0; int d=2; int div =0; while(d*d< n ){ if ( n%d==0 ) { if ( n/d>=3) { div++; if (d>=3)div++; } } d++; } //d*d>=n if (d*d==n) div += 1; return div; } int main() { int n; cin>>n; int64_t solutions = 0; int d=1; while(d*d< n ) { if (n % d == 0) { solutions += divisors(d - 1) + divisors((n / d - 1)); } d++; } //d*d>=n if (d*d==n) solutions +=divisors(d); cout<<solutions<<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 | #include <iostream> using namespace std; int divisors(int n); int divisors(int n) { if (n<6) return 0; int d=2; int div =0; while(d*d< n ){ if ( n%d==0 ) { if ( n/d>=3) { div++; if (d>=3)div++; } } d++; } //d*d>=n if (d*d==n) div += 1; return div; } int main() { int n; cin>>n; int64_t solutions = 0; int d=1; while(d*d< n ) { if (n % d == 0) { solutions += divisors(d - 1) + divisors((n / d - 1)); } d++; } //d*d>=n if (d*d==n) solutions +=divisors(d); cout<<solutions<<endl; return 0; } |