結果

問題 No.2324 Two Countries within UEC
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-18 00:15:12
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,280 bytes
コンパイル時間 7,101 ms
コンパイル使用メモリ 158,512 KB
実行使用メモリ 178,992 KB
最終ジャッジ日時 2023-10-18 00:15:32
合計ジャッジ時間 17,988 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 271 ms
57,740 KB
testcase_01 AC 285 ms
57,788 KB
testcase_02 AC 115 ms
37,960 KB
testcase_03 AC 240 ms
53,800 KB
testcase_04 AC 249 ms
56,840 KB
testcase_05 AC 119 ms
38,224 KB
testcase_06 AC 150 ms
42,516 KB
testcase_07 AC 112 ms
37,168 KB
testcase_08 AC 222 ms
56,440 KB
testcase_09 AC 224 ms
54,324 KB
testcase_10 AC 288 ms
57,788 KB
testcase_11 AC 272 ms
57,788 KB
testcase_12 AC 138 ms
41,204 KB
testcase_13 AC 137 ms
41,220 KB
testcase_14 AC 115 ms
37,888 KB
testcase_15 AC 110 ms
37,168 KB
testcase_16 AC 224 ms
51,684 KB
testcase_17 AC 171 ms
44,820 KB
testcase_18 AC 117 ms
38,300 KB
testcase_19 AC 304 ms
57,844 KB
testcase_20 AC 105 ms
36,388 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 285 ms
57,788 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 78 ms
32,476 KB
testcase_32 AC 78 ms
32,476 KB
testcase_33 AC 78 ms
32,476 KB
testcase_34 AC 78 ms
32,476 KB
testcase_35 AC 78 ms
32,476 KB
testcase_36 AC 78 ms
32,488 KB
testcase_37 AC 79 ms
32,488 KB
testcase_38 AC 79 ms
32,488 KB
testcase_39 AC 80 ms
32,488 KB
testcase_40 AC 87 ms
32,488 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (100 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

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

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m, p, q) = (c[0], c[1], c[2], c[3]);
        var ans = new int[q];
        for (var u = 0; u < q; ++u)
        {
            c = NList;
            ans[u] = Country(m, c[0], c[1], p);
        }
        WriteLine(string.Join("\n", ans));
    }
    static int Country(int m, int x, int f, int p)
    {
        var revx = Exp(x, p - 2, p);
        var ex = (int)(f * revx % p);
        if (ex > m) return 0;
        return (m - ex) / p + (ex > 0 ? 1 : 0);
    }
    static int GCD(int a, int b)
    {
        if (a < b) return GCD(b, a);
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
    static long Exp(long n, long k, int mod)
    {
        if (k == 0) return 1;
        if (k == 1) return n % mod;
        var half = Exp(n, k / 2, mod);
        var result = (half * half) % mod;
        return ((k % 2) == 0) ? result : ((result * n) % mod);
    }
}
0