結果

問題 No.1352 Three Coins
ユーザー QCFium
提出日時 2021-01-17 14:39:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 1,842 ms
コンパイル使用メモリ 168,464 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 09:35:47
合計ジャッジ時間 4,095 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int gcd(int a, int b) {
	while (a && b) {
		if (a > b) a %= b;
		else b %= a;
	}
	return a + b;
}

int main() {
	int a = ri();
	int b = ri();
	int c = ri();
	if (gcd(gcd(a, b), c) != 1) {
		puts("INF");
		return 0;
	}
	
	int max = 2000 * 2000;
	std::vector<bool> ok(max);
	ok[0] = true;
	for (int i = 0; i < max; i++) {
		if (!ok[i]) continue;
		if (i + a < max) ok[i + a] = true;
		if (i + b < max) ok[i + b] = true;
		if (i + c < max) ok[i + c] = true;
	}
	printf("%d\n", (int) std::count(ok.begin(), ok.end(), 0));
	
	return 0;
}
0