#include<iostream>
#include<vector>
#include<cassert>
#include <algorithm>
#include <memory>
#include <tuple>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
int N;
void Solve(int N)
{
if (N < 6) {
cout << 0 << endl;
return;
}
int counter = 0;
int x, y;
x = 1;
y = 3;
while (x < N / 3) {
y = 2 * x + x;
int yEnd = (N - x) / 2;
if ((N - y) % (y - x) != 0)
{
--counter;
}
while (y <= yEnd) {
++counter;
do {
y += x;
} while ((N - y) % (y - x) != 0 && y <= yEnd);
}
do {
++x;
} while ((N - x) % x != 0);
}
cout << counter << endl;
}
int main()
{
std::cin >> N;
Solve(N);
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 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include<iostream> #include<vector> #include<cassert> #include <algorithm> #include <memory> #include <tuple> #include <cmath> #include <map> #include <set> #include <unordered_map> using namespace std; int N; void Solve(int N) { if (N < 6) { cout << 0 << endl; return; } int counter = 0; int x, y; x = 1; y = 3; while (x < N / 3) { y = 2 * x + x; int yEnd = (N - x) / 2; if ((N - y) % (y - x) != 0) { --counter; } while (y <= yEnd) { ++counter; do { y += x; } while ((N - y) % (y - x) != 0 && y <= yEnd); } do { ++x; } while ((N - x) % x != 0); } cout << counter << endl; } int main() { std::cin >> N; Solve(N); return 0; } |
English