結果

問題 No.894 二種類のバス
ユーザー bluemeganebluemegane
提出日時 2020-09-06 20:55:02
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 910 bytes
コンパイル時間 2,884 ms
コンパイル使用メモリ 66,968 KB
実行使用メモリ 22,880 KB
最終ジャッジ日時 2023-08-19 14:18:51
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
20,600 KB
testcase_01 AC 61 ms
22,656 KB
testcase_02 AC 62 ms
22,880 KB
testcase_03 AC 62 ms
20,768 KB
testcase_04 AC 63 ms
22,860 KB
testcase_05 AC 61 ms
20,592 KB
testcase_06 AC 62 ms
22,804 KB
testcase_07 AC 61 ms
20,668 KB
testcase_08 AC 60 ms
20,660 KB
testcase_09 AC 63 ms
20,872 KB
testcase_10 AC 62 ms
20,708 KB
testcase_11 AC 64 ms
20,612 KB
testcase_12 AC 58 ms
22,628 KB
testcase_13 WA -
testcase_14 AC 58 ms
22,652 KB
testcase_15 AC 62 ms
22,660 KB
testcase_16 AC 61 ms
20,664 KB
testcase_17 AC 59 ms
22,708 KB
testcase_18 AC 58 ms
20,580 KB
testcase_19 AC 56 ms
20,764 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--;
        if (tpLcm > 0)
        {
            var ans = tpa + tpb + 1 - tpLcm;
            Console.WriteLine(ans);
        }
        else
        {
            var ans = tpa + tpb + 1;
            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