結果

問題 No.1835 Generalized Monty Hall Problem
ユーザー 👑 kakel-sankakel-san
提出日時 2022-02-11 21:47:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 814 bytes
コンパイル時間 1,425 ms
コンパイル使用メモリ 65,836 KB
実行使用メモリ 23,976 KB
最終ジャッジ日時 2023-09-10 01:47:20
合計ジャッジ時間 3,294 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,780 KB
testcase_01 AC 63 ms
21,848 KB
testcase_02 AC 63 ms
21,992 KB
testcase_03 AC 64 ms
21,848 KB
testcase_04 AC 63 ms
21,948 KB
testcase_05 AC 63 ms
21,884 KB
testcase_06 AC 64 ms
21,860 KB
testcase_07 AC 64 ms
21,828 KB
testcase_08 AC 63 ms
21,824 KB
testcase_09 AC 64 ms
21,780 KB
testcase_10 AC 63 ms
21,788 KB
testcase_11 AC 63 ms
21,984 KB
testcase_12 AC 64 ms
23,976 KB
testcase_13 AC 63 ms
21,752 KB
testcase_14 AC 64 ms
19,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, m, k) = (c[0], c[1], c[2]);

        var ch = m * n - m;
        var pa = n * n - k * n - n;
        var gcd = GCD(ch, pa);
        ch /= gcd;
        pa /= gcd;
        if (ch * n < pa * m)
        {
            gcd = GCD(n, m);
            WriteLine($"{m / gcd} {n / gcd}");
        }
        else WriteLine($"{ch} {pa}");
    }
    static long GCD(long a, long b)
    {
        if (a < b) return GCD(b, a);
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
}
0