// yukicoder: No.634 硬貨の枚数1 // 2019.5.1 bal4u #include #define KMAX 4471 // 4471*4472/2 = 9997156 int t[KMAX+5], sz; int bsch(int x) { int m, l = 0, r = sz; while (l < r) { m = (l + r) >> 1; if (t[m] == x) return 1; if (t[m] < x) l = m + 1; else r = m; } return 0; } int main() { int a, k, N; scanf("%d", &N); sz = 0, k = 0, a = 0; while (1) { a += ++k; if (a == N) { puts("1"); return 0; } if (a > N) break; t[sz++] = a; } a = N >> 1; for (k = 0; t[k] <= a; k++) { if (bsch(N-t[k])) { puts("2"); return 0; } } puts("3"); return 0; }