#include <iostream> using namespace std; //#define D(x) x #define D(x) int w = 0,x; void test_b(int a, int b) { if(b>=2) { D(cout << x << ", " << a*x << ", " << a*b*x << "\n"); w++; } } void test_n2(int n2) { for(int a=2;a*a<=n2;a++) { if(n2%a==0) { test_b(a, n2/a-1); if(n2/a!=a) test_b(n2/a, a-1); } } } int main() { int n,n2; cin >> n; for(x = 1;x*x<=n;x++) { if(n%x==0) { test_n2(n/x-1); if(n/x!=x) test_n2(x-1); } } cout << w << "\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 36 37 38 39 40 41 | #include <iostream> using namespace std; //#define D(x) x #define D(x) int w = 0,x; void test_b(int a, int b) { if(b>=2) { D(cout << x << ", " << a*x << ", " << a*b*x << "\n"); w++; } } void test_n2(int n2) { for(int a=2;a*a<=n2;a++) { if(n2%a==0) { test_b(a, n2/a-1); if(n2/a!=a) test_b(n2/a, a-1); } } } int main() { int n,n2; cin >> n; for(x = 1;x*x<=n;x++) { if(n%x==0) { test_n2(n/x-1); if(n/x!=x) test_n2(x-1); } } cout << w << "\n"; } |