結果

問題 No.634 硬貨の枚数1
ユーザー koyoprokoyopro
提出日時 2020-07-19 00:28:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 147,508 KB
実行使用メモリ 159,672 KB
最終ジャッジ日時 2023-08-21 06:35:54
合計ジャッジ時間 8,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
159,016 KB
testcase_01 AC 53 ms
159,188 KB
testcase_02 AC 44 ms
159,084 KB
testcase_03 AC 45 ms
159,144 KB
testcase_04 AC 45 ms
159,256 KB
testcase_05 AC 45 ms
159,256 KB
testcase_06 AC 44 ms
159,216 KB
testcase_07 AC 45 ms
159,324 KB
testcase_08 AC 44 ms
158,932 KB
testcase_09 AC 45 ms
159,096 KB
testcase_10 AC 44 ms
159,168 KB
testcase_11 AC 45 ms
158,936 KB
testcase_12 AC 45 ms
159,036 KB
testcase_13 AC 45 ms
159,156 KB
testcase_14 AC 44 ms
159,372 KB
testcase_15 AC 45 ms
159,408 KB
testcase_16 AC 46 ms
159,328 KB
testcase_17 AC 46 ms
159,264 KB
testcase_18 AC 46 ms
159,016 KB
testcase_19 AC 45 ms
159,480 KB
testcase_20 AC 45 ms
159,388 KB
testcase_21 AC 45 ms
159,456 KB
testcase_22 AC 46 ms
159,200 KB
testcase_23 AC 45 ms
159,256 KB
testcase_24 AC 46 ms
159,140 KB
testcase_25 AC 45 ms
159,096 KB
testcase_26 AC 45 ms
159,080 KB
testcase_27 AC 44 ms
159,256 KB
testcase_28 AC 44 ms
159,144 KB
testcase_29 AC 43 ms
159,076 KB
testcase_30 AC 45 ms
159,008 KB
testcase_31 AC 43 ms
159,504 KB
testcase_32 AC 43 ms
158,928 KB
testcase_33 AC 45 ms
159,260 KB
testcase_34 AC 45 ms
159,004 KB
testcase_35 AC 45 ms
159,120 KB
testcase_36 AC 44 ms
159,484 KB
testcase_37 AC 45 ms
159,256 KB
testcase_38 AC 45 ms
159,060 KB
testcase_39 AC 46 ms
159,016 KB
testcase_40 AC 46 ms
159,320 KB
testcase_41 AC 45 ms
159,060 KB
testcase_42 AC 45 ms
159,016 KB
testcase_43 AC 44 ms
159,512 KB
testcase_44 AC 45 ms
159,156 KB
testcase_45 AC 45 ms
159,144 KB
testcase_46 AC 45 ms
159,116 KB
testcase_47 AC 44 ms
159,372 KB
testcase_48 AC 45 ms
159,084 KB
testcase_49 AC 45 ms
159,348 KB
testcase_50 AC 45 ms
159,568 KB
testcase_51 AC 45 ms
159,256 KB
testcase_52 AC 45 ms
159,200 KB
testcase_53 AC 45 ms
159,148 KB
testcase_54 AC 45 ms
159,080 KB
testcase_55 AC 45 ms
159,488 KB
testcase_56 AC 45 ms
159,476 KB
testcase_57 AC 46 ms
159,412 KB
testcase_58 AC 45 ms
159,376 KB
testcase_59 AC 45 ms
159,460 KB
testcase_60 AC 46 ms
159,468 KB
testcase_61 AC 46 ms
159,444 KB
testcase_62 AC 44 ms
159,368 KB
testcase_63 AC 46 ms
159,416 KB
testcase_64 AC 44 ms
159,420 KB
testcase_65 AC 45 ms
159,488 KB
testcase_66 AC 46 ms
159,624 KB
testcase_67 AC 46 ms
159,372 KB
testcase_68 AC 46 ms
159,460 KB
testcase_69 AC 43 ms
159,672 KB
testcase_70 AC 48 ms
159,664 KB
testcase_71 AC 48 ms
159,416 KB
testcase_72 AC 45 ms
159,484 KB
testcase_73 AC 54 ms
159,556 KB
testcase_74 AC 45 ms
159,360 KB
testcase_75 AC 44 ms
159,372 KB
testcase_76 AC 45 ms
159,036 KB
testcase_77 AC 45 ms
159,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/

int N;
vector<int> S; // 1枚で払える金額一覧
vector<int> C(2e7, 0); // SorDに入っている金額のチェック用
int MAX=1e7;

void solve() {
    cin>>N;
    
    REP(i,N+2) {
        int n = i * (i+1) / 2;
        if (n > N) break;
        S.push_back(n);
        C[n] = 1;
    }
    if (C[N]) {
        cout << 1 << endl;
        return;
    }
    for (int n:S) {
        if (C[N-n]) {
            cout << 2 << endl;
            return;
        }
    }
    cout << 3 << endl;
}
0