結果

問題 No.894 二種類のバス
ユーザー bluemeganebluemegane
提出日時 2020-09-06 20:48:34
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 65,360 KB
実行使用メモリ 22,856 KB
最終ジャッジ日時 2023-08-19 14:18:11
合計ジャッジ時間 3,826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,676 KB
testcase_01 AC 57 ms
20,828 KB
testcase_02 AC 56 ms
20,672 KB
testcase_03 AC 56 ms
20,628 KB
testcase_04 WA -
testcase_05 AC 57 ms
20,880 KB
testcase_06 AC 57 ms
20,696 KB
testcase_07 AC 56 ms
20,704 KB
testcase_08 AC 57 ms
18,620 KB
testcase_09 AC 57 ms
20,580 KB
testcase_10 AC 56 ms
20,632 KB
testcase_11 AC 57 ms
20,780 KB
testcase_12 AC 56 ms
18,644 KB
testcase_13 WA -
testcase_14 AC 56 ms
20,824 KB
testcase_15 AC 58 ms
20,732 KB
testcase_16 AC 57 ms
20,728 KB
testcase_17 AC 57 ms
18,560 KB
testcase_18 AC 57 ms
22,756 KB
testcase_19 AC 57 ms
20,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        var b = long.Parse(line[2]);
        var gcd = Gcd(a, b);
        var tpa = t / a;
        if (t % a == 0) tpa--;
        var tpb = t / b;
        if (t % b == 0) tpb--;
        var tpLcm = t * gcd / a / b;
        if (t * gcd / a % b == 0) tpLcm--;
        var ans = tpa + tpb + 1 - tpLcm;
        Console.WriteLine(ans);
    }
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}
0