#include <bits/stdc++.h> #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto &i : a) #define SZ(i) ((int)(i).size()) #define X first #define Y second #define PR std::pair #define PII std::pair<int, int> #define MP std::make_pair #define ll long long #define VI std::vector<int> VI get_divisors(int n){ VI ret; for(int i = 1; i*i<=n; ++i){ if(n%i == 0){ ret.push_back(i); if(i*i != n) ret.push_back(n/i); } } return ret; } ll ans, n; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cin >> n; TRAV(dv, get_divisors(n)) TRAV(xd, get_divisors(dv-1)) if(xd > 1 && (dv-1)/xd > 2) ans++; std::cout << 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 | #include <bits/stdc++.h> #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto &i : a) #define SZ(i) ((int)(i).size()) #define X first #define Y second #define PR std::pair #define PII std::pair<int, int> #define MP std::make_pair #define ll long long #define VI std::vector<int> VI get_divisors(int n){ VI ret; for(int i = 1; i*i<=n; ++i){ if(n%i == 0){ ret.push_back(i); if(i*i != n) ret.push_back(n/i); } } return ret; } ll ans, n; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cin >> n; TRAV(dv, get_divisors(n)) TRAV(xd, get_divisors(dv-1)) if(xd > 1 && (dv-1)/xd > 2) ans++; std::cout << ans; return 0; } |