結果
| 問題 |
No.634 硬貨の枚数1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-20 01:30:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 569 bytes |
| コンパイル時間 | 1,752 ms |
| コンパイル使用メモリ | 168,372 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-25 20:54:18 |
| 合計ジャッジ時間 | 4,690 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a;
for (int i = 1; i * (i + 1) / 2 <= n; i++) {
a.push_back(i * (i + 1) / 2);
if (a.back() == n) {
cout << 1 << endl;
return 0;
}
}
for (int x : a) {
for (int y : a) {
if (x + y == n) {
cout << 2 << endl;
return 0;
}
}
}
cout << 3 << endl;
return 0;
}