結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
|
提出日時 | 2018-01-19 21:31:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 738 ms |
コンパイル使用メモリ | 72,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 18:37:48 |
合計ジャッジ時間 | 2,960 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { long long n; cin >> n; vector<long long> a; for (long long i = 1; i < 10000; i++) { a.push_back(i * (i + 1) / 2); } if (binary_search(a.begin(), a.end(), n)) { cout << 1 << endl; } else { for (long long x : a) { if (binary_search(a.begin(), a.end(), n - x)) { cout << 2 << endl; return 0; } } cout << 3 << endl; } }