#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> using namespace std; //a + ak + akl = n //a(1 + k + kl) = n //a * (1 + k(1 + l)) = n; int cf(int n) { if (n==4) return 0; int ret = 0; for (int i=2;i*i<=n;i++) { if (n%i==0) { ret++; if (i > 2 && i*i < n) { ret++; } } } return ret; } int main() { int n; cin >> n; int ret = 0; for (int i=1;i*i<=n;i++) { if (n%i == 0) { ret += cf(i-1); if (i*i<n) { ret += cf(n/i-1); } } } cout << ret << 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 | #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> using namespace std; //a + ak + akl = n //a(1 + k + kl) = n //a * (1 + k(1 + l)) = n; int cf(int n) { if (n==4) return 0; int ret = 0; for (int i=2;i*i<=n;i++) { if (n%i==0) { ret++; if (i > 2 && i*i < n) { ret++; } } } return ret; } int main() { int n; cin >> n; int ret = 0; for (int i=1;i*i<=n;i++) { if (n%i == 0) { ret += cf(i-1); if (i*i<n) { ret += cf(n/i-1); } } } cout << ret << endl; return 0; } |