結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

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

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

    int ans = 3;
    for (int i = 1; f(i) <= n; i++) {
        if (f(i) == n) ans = 1;

        int t = n - f(i);
        for (int j = i; f(j) <= t; j++) {
            if (f(j) == t) {
                ans = min(ans, 2);
            }
        }
    }

    cout << ans << endl;
    return 0;
}
0