/* -*- coding: utf-8 -*- * * 634.cc: No.634 硬貨の枚数1 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_M = 10000; /* typedef */ typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ int as[MAX_M]; /* subroutines */ /* main */ int main() { int n; cin >> n; int m = 0, sum = 0; for (int i = 1; sum + i <= n; i++, m++) { sum += i; as[m] = sum; //printf("as[%d]=%d\n", m, sum); } if (as[m - 1] == n) { puts("1"); return 0; } for (int i = 0; i < m; i++) { int k = lower_bound(as, as + m, n - as[i]) - as; if (k < m && as[k] == n - as[i]) { puts("2"); return 0; } } puts("3"); return 0; }