結果

問題 No.2324 Two Countries within UEC
ユーザー AdamantiteAdamantite
提出日時 2023-06-29 01:37:08
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,603 bytes
コンパイル時間 10,067 ms
コンパイル使用メモリ 145,400 KB
実行使用メモリ 165,216 KB
最終ジャッジ日時 2023-09-19 05:50:59
合計ジャッジ時間 25,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 583 ms
47,432 KB
testcase_02 AC 146 ms
34,040 KB
testcase_03 AC 441 ms
42,384 KB
testcase_04 WA -
testcase_05 AC 153 ms
32,084 KB
testcase_06 WA -
testcase_07 AC 132 ms
31,584 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 581 ms
47,116 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 204 ms
34,432 KB
testcase_14 AC 144 ms
31,980 KB
testcase_15 WA -
testcase_16 AC 410 ms
41,076 KB
testcase_17 AC 282 ms
36,576 KB
testcase_18 WA -
testcase_19 AC 572 ms
47,452 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 572 ms
47,176 KB
testcase_26 AC 403 ms
46,320 KB
testcase_27 AC 407 ms
47,728 KB
testcase_28 AC 402 ms
46,316 KB
testcase_29 AC 405 ms
46,512 KB
testcase_30 AC 412 ms
46,304 KB
testcase_31 AC 52 ms
28,608 KB
testcase_32 AC 53 ms
28,612 KB
testcase_33 AC 53 ms
28,708 KB
testcase_34 AC 52 ms
28,552 KB
testcase_35 WA -
testcase_36 AC 53 ms
28,456 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 52 ms
28,616 KB
testcase_41 WA -
testcase_42 AC 54 ms
165,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 185 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;

namespace No02324_TwoCountriesWithinUEC
{
    internal class Program
    {
        static void Main(string[] args) {
            string[] param = Console.ReadLine().Split(' ');
            int n = int.Parse(param[0]);
            int m = int.Parse(param[1]);
            int p = int.Parse(param[2]);
            int q = int.Parse(param[3]);

            int[] result = new int[q];
            for (int i = 0; i < q; i++) {
                string[] param2 = Console.ReadLine().Split(' ');
                int x = int.Parse(param2[0]);
                int f = int.Parse(param2[1]);

                int xMod = x % p;
                if (xMod == 0) {
                    if (f == 0) {
                        result[i] = m;
                    } else {
                        result[i] = 0;
                    }
                } else {
                    long y = f * RepPow(x, p - 2, p) % p;
                    if (y != 0 && y <= m) {
                        result[i] = m / p + 1;
                    } else {
                        result[i] = m / p;
                    }
                }
            }
            for (int i = 0; i < q; i++) {
                Console.WriteLine(result[i]);
            }
        }

        //x^p % mod
        static long RepPow(long n, long p, int mod) {
            if (p == 0) {
                return 1;
            }
            if (p % 2 == 0) {
                var x = RepPow(n, p / 2, mod);
                return (x * x) % mod;
            } else {
                return RepPow(n, p - 1, mod) * n % mod;
            }
        }
    }
}
0