結果
| 問題 |
No.634 硬貨の枚数1
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-16 11:29:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 1,351 ms |
| コンパイル使用メモリ | 162,616 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-11-16 11:29:26 |
| 合計ジャッジ時間 | 4,045 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n, res = 3;
map<int, bool> vis;
signed main()
{
// freopen("coin.in", "r", stdin);
// freopen("coin.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i * (i + 1) / 2 <= n; i++)
{
if (i * (i + 1) / 2 == n)
{
res = 1;
break;
}
vis[i * (i + 1) / 2] = 1;
if (vis.count(n - i * (i + 1) / 2))
{
res = min(res, 2ll);
}
}
cout << res;
}
vjudge1