結果

問題 No.1835 Generalized Monty Hall Problem
ユーザー ks2mks2m
提出日時 2022-02-11 21:54:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 479 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 74,180 KB
実行使用メモリ 57,008 KB
最終ジャッジ日時 2023-09-10 02:10:27
合計ジャッジ時間 5,492 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
56,556 KB
testcase_01 AC 148 ms
56,560 KB
testcase_02 AC 149 ms
56,820 KB
testcase_03 AC 147 ms
56,940 KB
testcase_04 AC 150 ms
56,968 KB
testcase_05 AC 150 ms
56,920 KB
testcase_06 AC 151 ms
56,640 KB
testcase_07 AC 147 ms
56,788 KB
testcase_08 AC 148 ms
56,852 KB
testcase_09 AC 148 ms
57,008 KB
testcase_10 AC 151 ms
56,708 KB
testcase_11 AC 151 ms
56,624 KB
testcase_12 AC 149 ms
56,624 KB
testcase_13 AC 149 ms
56,552 KB
testcase_14 AC 150 ms
57,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long k = sc.nextInt();
		sc.close();

		long p1 = m * (m - 1);
		long p2 = (n - m) * m;
		long p = p1 + p2;
		long q = n * (n - k - 1);
		long g = gcd(p, q);
		System.out.println(p / g + " " + q / g);
	}

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}
0