結果

問題 No.894 二種類のバス
ユーザー bluemeganebluemegane
提出日時 2020-09-06 20:48:34
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 108,580 KB
実行使用メモリ 24,024 KB
最終ジャッジ日時 2024-05-06 21:26:02
合計ジャッジ時間 2,012 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
17,536 KB
testcase_01 AC 23 ms
17,920 KB
testcase_02 AC 22 ms
17,536 KB
testcase_03 AC 23 ms
17,792 KB
testcase_04 WA -
testcase_05 AC 24 ms
17,792 KB
testcase_06 AC 23 ms
17,664 KB
testcase_07 AC 24 ms
17,536 KB
testcase_08 AC 25 ms
17,792 KB
testcase_09 AC 24 ms
17,792 KB
testcase_10 AC 23 ms
17,664 KB
testcase_11 AC 24 ms
17,792 KB
testcase_12 AC 24 ms
18,048 KB
testcase_13 WA -
testcase_14 AC 23 ms
17,920 KB
testcase_15 AC 24 ms
17,792 KB
testcase_16 AC 24 ms
17,920 KB
testcase_17 AC 23 ms
17,664 KB
testcase_18 AC 22 ms
17,664 KB
testcase_19 AC 23 ms
17,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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