結果

問題 No.1352 Three Coins
ユーザー blackyukiblackyuki
提出日時 2021-01-13 20:04:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 206,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 05:49:37
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 31 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 32 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 AC 19 ms
5,376 KB
testcase_11 AC 21 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 30 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 42 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 24 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 40 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 28 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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