結果

問題 No.1352 Three Coins
コンテスト
ユーザー blackyuki
提出日時 2021-01-13 20:04:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 3,170 ms
コンパイル使用メモリ 198,800 KB
最終ジャッジ日時 2025-01-17 17:33:27
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;cin>>a>>b>>c;
    assert(1<=a&&a<=2000);
    assert(1<=b&&b<=2000);
    assert(1<=c&&c<=2000);
    if(__gcd(a,__gcd(b,c))!=1){
        cout<<"INF"<<endl;
        return 0;
    }
    vector<bool> dp(a*b+5,false);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        auto t=q.front();q.pop();
        if(t+a<dp.size()&&!dp[t+a]){
            dp[t+a]=true;q.push(t+a);
        }
        if(t+b<dp.size()&&!dp[t+b]){
            dp[t+b]=true;q.push(t+b);
        }
        if(t+c<dp.size()&&!dp[t+c]){
            dp[t+c]=true;q.push(t+c);
        }
    }
    int ans=0;
    for(int i=1;i<a*b+5;i++)if(!dp[i])ans++;
    cout<<ans<<endl;
}
0