#include<bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define CLR(a) memset(a, 0, sizeof(a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) ) #define S(X) ( (X) * (X) ) #define SZ(V) (int )V.size() #define FORN(i, n) for(i = 0; i < n; i++) #define FORAB(i, a, b) for(i = a; i <= b; i++) #define ALL(V) V.begin(), V.end() #define IN(A, B, C) ((B) <= (A) && (A) <= (C)) #define AIN(A, B, C) assert(IN(A, B, C)) typedef pair<int,int> PII; typedef pair<double, double> PDD; typedef vector<int> VI; typedef vector<PII> VP; //typedef int LL; typedef long long int LL; LL ans = 0; void check2(int q, int n) { n /= q; n--; ans += n > 1; } void check(int p, int n) { n /= p; n--; for (int q = 2; q * q <= n; q++) { if (n % q) continue; check2(q, n); if (q * q != n) check2(n/q, n); } } int main() { int n; scanf("%d", &n); for (int p = 1; p * p <= n; p++) { if (n % p) continue; check(p, n); if (p * p != n) check(n/p, n); } printf("%lld\n", ans); 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 | #include<bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define CLR(a) memset(a, 0, sizeof(a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) ) #define S(X) ( (X) * (X) ) #define SZ(V) (int )V.size() #define FORN(i, n) for(i = 0; i < n; i++) #define FORAB(i, a, b) for(i = a; i <= b; i++) #define ALL(V) V.begin(), V.end() #define IN(A, B, C) ((B) <= (A) && (A) <= (C)) #define AIN(A, B, C) assert(IN(A, B, C)) typedef pair<int,int> PII; typedef pair<double, double> PDD; typedef vector<int> VI; typedef vector<PII> VP; //typedef int LL; typedef long long int LL; LL ans = 0; void check2(int q, int n) { n /= q; n--; ans += n > 1; } void check(int p, int n) { n /= p; n--; for (int q = 2; q * q <= n; q++) { if (n % q) continue; check2(q, n); if (q * q != n) check2(n/q, n); } } int main() { int n; scanf("%d", &n); for (int p = 1; p * p <= n; p++) { if (n % p) continue; check(p, n); if (p * p != n) check(n/p, n); } printf("%lld\n", ans); return 0; } |