結果

問題 No.634 硬貨の枚数1
ユーザー hrgn
提出日時 2019-07-20 07:26:32
言語 C++14
(gcc 8.2.0)
結果
AC  
実行時間 8 ms
コード長 491 Byte
コンパイル時間 1,250 ms
使用メモリ 8,920 KB
最終ジャッジ日時 2019-07-20 07:26:36

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample1.txt AC 3 ms
6,872 KB
00_sample2.txt AC 4 ms
6,868 KB
00_sample3.txt AC 3 ms
6,868 KB
10_small_r_00.txt AC 3 ms
6,872 KB
10_small_r_01.txt AC 3 ms
8,916 KB
10_small_r_02.txt AC 3 ms
6,868 KB
10_small_r_03.txt AC 3 ms
6,872 KB
10_small_r_04.txt AC 3 ms
6,872 KB
10_small_r_05.txt AC 2 ms
6,872 KB
10_small_r_06.txt AC 3 ms
6,872 KB
10_small_r_07.txt AC 4 ms
6,872 KB
10_small_r_08.txt AC 2 ms
8,912 KB
10_small_r_09.txt AC 3 ms
6,868 KB
10_small_r_20.txt AC 3 ms
6,868 KB
11_large_r_00.txt AC 3 ms
6,872 KB
11_large_r_01.txt AC 7 ms
6,872 KB
11_large_r_02.txt AC 6 ms
6,872 KB
11_large_r_03.txt AC 4 ms
6,868 KB
11_large_r_04.txt AC 5 ms
6,872 KB
11_large_r_05.txt AC 7 ms
6,868 KB
11_large_r_06.txt AC 7 ms
6,868 KB
11_large_r_07.txt AC 8 ms
6,872 KB
11_large_r_08.txt AC 6 ms
6,872 KB
11_large_r_09.txt AC 4 ms
6,868 KB
20_small_d_00.txt AC 3 ms
8,916 KB
20_small_d_01.txt AC 2 ms
8,920 KB
20_small_d_02.txt AC 2 ms
6,872 KB
20_small_d_03.txt AC 2 ms
6,872 KB
20_small_d_04.txt AC 3 ms
6,872 KB
20_small_d_05.txt AC 3 ms
6,868 KB
20_small_d_06.txt AC 2 ms
6,872 KB
20_small_d_07.txt AC 2 ms
6,872 KB
20_small_d_08.txt AC 2 ms
6,868 KB
20_small_d_09.txt AC 3 ms
6,872 KB
21_large_d_00.txt AC 1 ms
6,872 KB
21_large_d_01.txt AC 2 ms
6,872 KB
21_large_d_02.txt AC 6 ms
6,872 KB
21_large_d_03.txt AC 5 ms
6,868 KB
21_large_d_04.txt AC 3 ms
6,872 KB
21_large_d_05.txt AC 8 ms
6,872 KB
21_large_d_06.txt AC 6 ms
6,872 KB
21_large_d_07.txt AC 6 ms
6,868 KB
21_large_d_08.txt AC 6 ms
6,868 KB
21_large_d_09.txt AC 4 ms
8,920 KB
30_hand00.txt AC 3 ms
6,872 KB
30_hand01.txt AC 3 ms
6,872 KB
30_hand02.txt AC 4 ms
6,868 KB
30_hand03.txt AC 8 ms
6,868 KB
30_hand04.txt AC 2 ms
6,872 KB
30_hand05.txt AC 2 ms
6,872 KB
30_hand06.txt AC 8 ms
6,872 KB
30_hand07.txt AC 4 ms
6,872 KB
31_hand00.txt AC 3 ms
6,872 KB
31_hand01.txt AC 4 ms
6,872 KB
31_hand02.txt AC 3 ms
6,868 KB
40_extra_01.txt AC 8 ms
6,868 KB
40_extra_02.txt AC 8 ms
6,872 KB
40_extra_03.txt AC 8 ms
6,872 KB
40_extra_04.txt AC 8 ms
6,872 KB
40_extra_05.txt AC 8 ms
6,868 KB
40_extra_06.txt AC 8 ms
6,868 KB
40_extra_07.txt AC 8 ms
6,872 KB
40_extra_08.txt AC 8 ms
6,868 KB
40_extra_09.txt AC 8 ms
6,872 KB
40_extra_10.txt AC 8 ms
6,872 KB
40_extra_11.txt AC 8 ms
6,872 KB
40_extra_12.txt AC 8 ms
6,872 KB
40_extra_13.txt AC 8 ms
6,872 KB
40_extra_14.txt AC 8 ms
8,916 KB
40_extra_15.txt AC 8 ms
6,868 KB
40_extra_16.txt AC 8 ms
6,872 KB
40_extra_17.txt AC 7 ms
6,868 KB
40_extra_18.txt AC 8 ms
6,868 KB
40_extra_19.txt AC 7 ms
6,872 KB
40_extra_20.txt AC 8 ms
8,920 KB
40_extra_21.txt AC 8 ms
6,868 KB
99_system_test1.txt AC 4 ms
6,868 KB
99_system_test2.txt AC 3 ms
6,868 KB
テストケース一括ダウンロード

ソースコード

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;
            break;
        }

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

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