結果

問題 No.634 硬貨の枚数1
ユーザー aitdccd
提出日時 2018-01-25 20:43:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 487 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 165,268 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 15:41:32
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 74 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;


int f(int n) {
    return n * (n + 1) / 2;
}

int main() {
    int n;
    cin >> n;

    for (int i = 1; f(i) <= n; i++) {
        if (f(i) == n) {
            cout << 1 << endl;
            return 0;
        }
        int t = n - f(i);
        for (int j = i; f(j) <= t; j++) {
            if (f(j) == t) {
                cout << 2 << endl;
                return 0;
            }
        }
    }

    cout << 3 << endl;
    return 0;
}
0