結果
| 問題 | No.1352 Three Coins |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-24 13:41:25 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 711 bytes |
| 記録 | |
| コンパイル時間 | 659 ms |
| コンパイル使用メモリ | 90,368 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-17 09:40:43 |
| 合計ジャッジ時間 | 2,663 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
#line 1 "main.cpp"
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
constexpr int X = 10000000;
void solve() {
int a, b, c;
cin >> a >> b >> c;
if (gcd(gcd(a, b), c) != 1) {
cout << "INF\n";
return;
}
vector<bool> ok(X + 1, false);
ok[0] = true;
int ans = 0;
for (int x = 0; x <= X; ++x) {
if (ok[x]) {
if (x + a <= X) ok[x + a] = true;
if (x + b <= X) ok[x + b] = true;
if (x + c <= X) ok[x + c] = true;
} else {
++ans;
}
}
cout << ans << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}