結果
| 問題 |
No.634 硬貨の枚数1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-18 03:16:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 545 bytes |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 75,568 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-11-18 03:16:18 |
| 合計ジャッジ時間 | 3,229 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
#include <unordered_set>
using namespace std;
const int N = 4510;
int n, a[N], cnt;
unordered_set<int> s;
int main() {
for (int i = 1; i < N; ++i) {
a[i] = i * (i + 1) / 2;
s.insert(a[i]);
}
scanf("%d", &n);
cnt = 3;
if (s.count(n)) cnt = 1;
else {
for (int i = 1; i < N; ++i) {
if (n - a[i] < 0) break;
if (s.count(n - a[i])) {
cnt = 2;
break;
}
}
}
printf("%d\n", cnt);
return 0;
}