結果

問題 No.634 硬貨の枚数1
ユーザー kagasan
提出日時 2019-08-24 19:36:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 174,472 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 13:12:18
合計ジャッジ時間 4,487 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    vector<ll>v;
    set<ll>S;
    for(ll i = 1; ; i++){
        ll t = i * (i + 1) / 2;
        if(t > 10000000)break;
        v.push_back(t);
        S.insert(t);
    }
    ll N;
    cin >> N;
    ll ans = 3;
    if(S.find(N) != S.end())ans = 1;
    for(ll i = 0; i < v.size(); i++){
        for(ll j = i; j < v.size(); j++){
            if(v[i] + v[j] == N)ans = min(ans, 2LL);
        }
    }
    cout << ans << endl;


    return 0;
}
0