結果

問題 No.894 二種類のバス
ユーザー hayashihayashi
提出日時 2019-10-16 12:10:21
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,416 bytes
コンパイル時間 4,172 ms
コンパイル使用メモリ 104,156 KB
実行使用メモリ 28,696 KB
最終ジャッジ日時 2023-09-02 13:54:22
合計ジャッジ時間 9,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

using System;
namespace algo {
    class Program
    {
        static void Main(string[] args)
        {
            string[] N = Console.ReadLine().Split(' ');
            ulong T = ulong.Parse(N[0]);
            ulong A = ulong.Parse(N[1]);
            ulong B = ulong.Parse(N[2]);
            ulong ans = 1;
            ulong a= 1;
            ulong i = 2;
            while (true)
            {
                if( A % i == 0 && B % i == 0)
                {
                    a *= i;
                    A /= i;
                    B /= i;
                }
                else
                {
                    i++;
                }
                if(A < 4 || B < 4)
                {
                    a *= A * B;
                    break;
                }
            }
            A = ulong.Parse(N[1]);
            B = ulong.Parse(N[2]);
            if(T % A == 0)
            {
                ans += T / A - 1;
            }
            else
            {
                ans += T / A;
            }
            if (T % B == 0)
            {
                ans += T / B - 1;
            }
            else
            {
                ans += T / B;
            }
            if(T > a && T % a != 0)
            {
                ans -= T / a;
            }
            else
            {
                ans -= T / a - 1;
            }
            Console.WriteLine(ans);
        }
    }
}
0