結果
| 問題 | 
                            No.634 硬貨の枚数1
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tokizo
                         | 
                    
| 提出日時 | 2019-03-09 20:26:08 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 14 ms / 2,000 ms | 
| コード長 | 945 bytes | 
| コンパイル時間 | 1,719 ms | 
| コンパイル使用メモリ | 172,048 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-23 15:15:09 | 
| 合計ジャッジ時間 | 3,869 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 75 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A;
    int t, c = 1;
    while(true){
        t = c * (c + 1) / 2;
        if(t > n) break;
        if(n == t){
            cout << 1 << endl;
            return 0;
        }
        A.push_back(t);
        c++;
    }
    sort(A.begin(), A.end());
    for(int i = 0; i < A.size(); i++){
        for(int j = i; j < A.size(); j++){
            if(A[i] + A[j] == n){
                cout << 2 << endl;
                return 0;
            }
        }
    }
    cout << 3 << endl;
    /*
    int dp[n + 1];
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = 1e9;
    }
    dp[1] = 1;
    for(int i = 1; i <= n; i++){
        for(auto x : A){
            if(i - x >= 0){
                dp[i] = min(dp[i], dp[i - x] + 1);
            }
        }
    }
    */
    return 0;
}
            
            
            
        
            
tokizo