結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2017-05-16 14:57:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 492 bytes |
コンパイル時間 | 1,836 ms |
コンパイル使用メモリ | 165,852 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 18:19:36 |
合計ジャッジ時間 | 3,790 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; unordered_set<int> exists; vector<int> T; for (int t, i = 1; (t = i * (i + 1) / 2) <= n; i++) { if (t == n) { cout << 1 << endl; return 0; } T.emplace_back(t); exists.insert(t); } for (int t : T) { if (exists.count(n - t)) { cout << 2 << endl; return 0; } } cout << 3 << endl; return 0; }