結果

問題 No.894 二種類のバス
ユーザー bluemeganebluemegane
提出日時 2020-09-06 20:50:58
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 65,180 KB
実行使用メモリ 22,772 KB
最終ジャッジ日時 2023-08-19 14:18:14
合計ジャッジ時間 2,872 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,732 KB
testcase_01 AC 58 ms
20,876 KB
testcase_02 AC 57 ms
20,632 KB
testcase_03 AC 57 ms
20,624 KB
testcase_04 WA -
testcase_05 AC 56 ms
20,688 KB
testcase_06 AC 57 ms
22,748 KB
testcase_07 AC 57 ms
22,724 KB
testcase_08 AC 56 ms
20,876 KB
testcase_09 AC 57 ms
22,644 KB
testcase_10 AC 58 ms
20,632 KB
testcase_11 AC 56 ms
18,524 KB
testcase_12 AC 57 ms
20,688 KB
testcase_13 WA -
testcase_14 AC 56 ms
20,700 KB
testcase_15 AC 56 ms
20,612 KB
testcase_16 AC 57 ms
22,760 KB
testcase_17 AC 57 ms
18,732 KB
testcase_18 AC 58 ms
20,824 KB
testcase_19 AC 56 ms
20,772 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