結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
![]() |
提出日時 | 2020-10-10 07:51:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 529 bytes |
コンパイル時間 | 1,610 ms |
コンパイル使用メモリ | 171,476 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 15:39:46 |
合計ジャッジ時間 | 3,499 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; set<ll> s; ll val{ 0 }, i{ 1 }; while (val < n) { val = i * (i + 1) / 2; s.insert(val); ++i; } int res = 3; if (s.count(n)) res = 1; else { for (auto it = s.crbegin(); it != s.crend(); ++it) { if (s.count(n - *it)) { res = 2; break; } } } cout << res << "\n"; return 0; }