結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
|
提出日時 | 2018-09-20 15:15:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 755 ms |
コンパイル使用メモリ | 73,448 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-18 08:34:01 |
合計ジャッジ時間 | 3,043 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ vector<int> v; for(int i = 1; i*(i+1) <= 20000000; i++) v.push_back(i*(i+1)/2); int n; cin >> n; if(*lower_bound(v.begin(), v.end(), n) == n){ cout << 1 << endl; }else{ bool judge = false; for(int x : v){ if(x > n) break; if(*lower_bound(v.begin(), v.end(), n-x) == n-x) judge = true; } if(judge) cout << 2 << endl; else cout << 3 << endl; } return 0; }