#include #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define triangular k * (k + 1) / 2 using namespace std; int main() { int N; cin >> N; set triangularNum; int answer = 3; //Nまでの三角数のリストを作成 for(int k = 1; triangular <= N; ++k) triangularNum.insert(triangular); if(triangularNum.count(N)) answer = 1; else { //2つの三角数で表せるか総当り for(auto hoge : triangularNum) { if(hoge * triangularNum.count(N - hoge)) { answer = 2; break; } } } cout << answer << '\n'; }