#include <iostream> #include <cmath> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char** argv) { int n; cin >> n; int counter = 0; for(int a = 1; a<=sqrt(n); a++){ if(n%a==0){ int n1 = n/a - 1; for(int k=2; k<=sqrt(n1); k++){ if(n1%k==0){ int n2=n1/k-1; if(n2>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } int n3=n1/(n1/k)-1; if(n3==n2){ break; } if(n3>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } } } n1 = n/(n/a)-1; for(int k=2; k<=sqrt(n1); k++){ if(n1%k==0){ int n2=n1/k-1; if(n2>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } int n3=n1/(n1/k)-1; if(n3==n2){ break; } if(n3>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } } } } } cout << counter; 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #include <iostream> #include <cmath> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char** argv) { int n; cin >> n; int counter = 0; for(int a = 1; a<=sqrt(n); a++){ if(n%a==0){ int n1 = n/a - 1; for(int k=2; k<=sqrt(n1); k++){ if(n1%k==0){ int n2=n1/k-1; if(n2>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } int n3=n1/(n1/k)-1; if(n3==n2){ break; } if(n3>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } } } n1 = n/(n/a)-1; for(int k=2; k<=sqrt(n1); k++){ if(n1%k==0){ int n2=n1/k-1; if(n2>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } int n3=n1/(n1/k)-1; if(n3==n2){ break; } if(n3>=2){ //cout << counter << " test 1: " << a << ", " << a*k << ", " << a*k*n2 << "=" << a+a*k+a*k*n2 << endl; counter++; } } } } } cout << counter; return 0; } |