結果

問題 No.1352 Three Coins
ユーザー ぷらぷら
提出日時 2021-01-17 14:01:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 164,116 KB
実行使用メモリ 34,820 KB
最終ジャッジ日時 2023-08-24 23:04:59
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
34,608 KB
testcase_01 AC 16 ms
34,812 KB
testcase_02 AC 16 ms
34,672 KB
testcase_03 AC 17 ms
34,672 KB
testcase_04 AC 17 ms
34,680 KB
testcase_05 AC 16 ms
34,684 KB
testcase_06 AC 17 ms
34,608 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 17 ms
34,664 KB
testcase_09 AC 17 ms
34,636 KB
testcase_10 AC 17 ms
34,624 KB
testcase_11 AC 17 ms
34,620 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 17 ms
34,648 KB
testcase_14 AC 17 ms
34,588 KB
testcase_15 AC 17 ms
34,536 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 17 ms
34,560 KB
testcase_18 AC 17 ms
34,512 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 17 ms
34,656 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 17 ms
34,516 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 18 ms
34,636 KB
testcase_28 AC 17 ms
34,820 KB
testcase_29 AC 17 ms
34,760 KB
testcase_30 AC 16 ms
33,312 KB
testcase_31 AC 17 ms
34,672 KB
testcase_32 AC 15 ms
33,440 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 17 ms
34,672 KB
testcase_35 AC 16 ms
34,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 3e18+7;
int mod = 1e9+7;
int dx[] = {1, 0,-1, 0, 1, 1,-1,-1};
int dy[] = {0, 1, 0,-1, 1,-1, 1,-1};
int gcd(int X,int Y) {
    if(X%Y == 0) {
        return Y;
    }
    else {
        return gcd(Y,X%Y);
    }
}
int dp[4003000];
signed main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(gcd(gcd(A,B),C) != 1) {
        cout << "INF" << endl;
        return 0;
    }
    int ans = 0;
    dp[0] = 1;
    for(int i = 0; i <= 4000000; i++) {
        if(dp[i] == 1) {
            dp[i+A] = 1;
            dp[i+B] = 1;
            dp[i+C] = 1;
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}
0