結果

問題 No.634 硬貨の枚数1
ユーザー ganariya
提出日時 2018-01-19 23:40:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 75,432 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 20:32:14
合計ジャッジ時間 7,680 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

void makeCoins(int *coins){
    coins[0]=1;
    for(int i=1;i<9999;i++){
        coins[i]=coins[i-1]+(i+1);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int coins[10000];
    makeCoins(coins);

    int N;scanf("%d",&N);

    int answer=-1;
    for(int i=0;i<9999;i++){
        if(coins[i]==N){
            answer=1;
            break;
        }
    }
    if(answer==-1) {
        for (int i = 0; i < 9999; i++) {
            for (int j = 0; j < 9999; j++) {
                if (coins[i] + coins[j] == N) {
                    answer = 2;
                }
            }
        }
    }
    if(answer==-1){
        answer=3;
    }

    printf("%d",answer);

    return 0;
}
0