結果

問題 No.1835 Generalized Monty Hall Problem
ユーザー mannshi222jpmannshi222jp
提出日時 2022-02-11 23:45:03
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 28,136 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 06:47:11
合計ジャッジ時間 1,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long int N, M, K;

long long int euc( long long int a, long long int b );

int main()
{
        scanf( "%lld %lld %lldn\n", &N, &M, &K );
        long long int Q, P1, P2, P;
        long long int y;

        Q = N * ( N - K -1 );
        P1 = M * ( N - K -1 );
        //P2 = M * ( N - M ) + M * ( M -1 );
        P2 = M * (  N -  1 );

        P = P1 > P2 ? P1 : P2;
        y = euc( P, Q );
#ifdef DEDBUG
        printf("%lld %lld %lld %lld\n", P1, P2, Q, y );
#endif


#ifdef DEBUG
        printf("%lld %lld %lld %lld\n", P1, P2, Q, y );
#endif
        printf("%lld %lld\n", P/y, Q/y );
        return 0;
}
long long int euc( long long int a, long long int b )
{
        int tmp, r;

        if( a < b ) {
                tmp = a;
                a = b;
                b = tmp;
        }

        r = a % b;
        while( r != 0 ) {
                a = b;
                b = r;
                r = a % b;
        }


        return b ;
}
0