結果
| 問題 |
No.1352 Three Coins
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-17 14:57:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 990 bytes |
| コンパイル時間 | 2,169 ms |
| コンパイル使用メモリ | 198,064 KB |
| 最終ジャッジ日時 | 2025-01-18 01:01:35 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int a,b,c; cin >> a >> b >> c;
if(__gcd(a,b)!=1 and __gcd(b,c)!=1 and __gcd(c,a)!=1 and __gcd(__gcd(a,b),c)!=1){
printf("INF\n");
}
else{
const int N=10000000;
vector<bool> dp(N,false);
dp[a]=true;
dp[b]=true;
dp[c]=true;
int res=0;
for(int i=1;i<N;i++){
if(!dp[i]){
res++;
continue;
}
if(i+a<N){
dp[i+a]=true;
}
if(i+b<N){
dp[i+b]=true;
}
if(i+c<N){
dp[i+c]=true;
}
}
printf("%d\n",res);
}
}