結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
![]() |
提出日時 | 2019-03-09 20:24:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 949 bytes |
コンパイル時間 | 1,845 ms |
コンパイル使用メモリ | 172,756 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 15:15:05 |
合計ジャッジ時間 | 4,276 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 74 WA * 1 |
ソースコード
#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 + 1; 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; }