結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2017-05-16 14:59:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 1,571 ms |
コンパイル使用メモリ | 159,708 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2024-12-25 18:19:41 |
合計ジャッジ時間 | 3,356 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include <bits/stdc++.h> using namespace std; bool exists[10000001]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; 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[t] = 1; } for (int t : T) { if (exists[n - t]) { cout << 2 << endl; return 0; } } cout << 3 << endl; return 0; }