#include <iostream>
#include <vector>
#include <algorithm>
std::vector<int> get_divs(int x) {
std::vector<int> res;
for(int i=1; i*i<=x; i++) {
if(!(x % i)) {
res.push_back(i);
if(i*i != x) {
res.push_back(x/i);
}
}
}
std::sort (res.begin(), res.end());
return res;
}
int main() {
int n, k, res=0;
std::vector<int> a, b;
std::cin >> n;
a = get_divs(n);
for(std::vector<int>::iterator ia=a.begin(); ia!=a.end(); ++ia) {
k = n/(*ia)-1;
b = get_divs(k);
for(std::vector<int>::iterator ib=b.begin(); ib!=b.end(); ++ib) {
if(*ib > 1 && k/(*ib) >2) {
// std::cout << *ia << ' ' << *ib**ia << ' ' << *ib*(k/(*ib)-1)**ia << std::endl;
res++;
}
}
}
std::cout << res << std::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 | #include <iostream> #include <vector> #include <algorithm> std::vector<int> get_divs(int x) { std::vector<int> res; for(int i=1; i*i<=x; i++) { if(!(x % i)) { res.push_back(i); if(i*i != x) { res.push_back(x/i); } } } std::sort (res.begin(), res.end()); return res; } int main() { int n, k, res=0; std::vector<int> a, b; std::cin >> n; a = get_divs(n); for(std::vector<int>::iterator ia=a.begin(); ia!=a.end(); ++ia) { k = n/(*ia)-1; b = get_divs(k); for(std::vector<int>::iterator ib=b.begin(); ib!=b.end(); ++ib) { if(*ib > 1 && k/(*ib) >2) { // std::cout << *ia << ' ' << *ib**ia << ' ' << *ib*(k/(*ib)-1)**ia << std::endl; res++; } } } std::cout << res << std::endl; return 0; } |
English