結果
| 問題 |
No.1835 Generalized Monty Hall Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-11 21:47:58 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,000 ms |
| コード長 | 814 bytes |
| コンパイル時間 | 2,959 ms |
| コンパイル使用メモリ | 105,728 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-06-27 17:54:13 |
| 合計ジャッジ時間 | 3,502 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}