結果

問題 No.2709 1975 Powers
ユーザー bluemeganebluemegane
提出日時 2024-04-04 16:09:56
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 1,461 ms / 2,000 ms
コード長 1,410 bytes
コンパイル時間 6,977 ms
コンパイル使用メモリ 158,296 KB
実行使用メモリ 241,596 KB
最終ジャッジ日時 2024-04-04 16:10:26
合計ジャッジ時間 26,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 188 ms
94,172 KB
testcase_01 AC 188 ms
94,172 KB
testcase_02 AC 200 ms
94,180 KB
testcase_03 AC 837 ms
94,352 KB
testcase_04 AC 1,238 ms
94,352 KB
testcase_05 AC 895 ms
94,352 KB
testcase_06 AC 410 ms
94,352 KB
testcase_07 AC 192 ms
94,180 KB
testcase_08 AC 385 ms
94,180 KB
testcase_09 AC 901 ms
94,352 KB
testcase_10 AC 190 ms
94,180 KB
testcase_11 AC 212 ms
94,180 KB
testcase_12 AC 242 ms
94,180 KB
testcase_13 AC 920 ms
94,352 KB
testcase_14 AC 315 ms
94,180 KB
testcase_15 AC 308 ms
94,180 KB
testcase_16 AC 749 ms
94,352 KB
testcase_17 AC 192 ms
94,180 KB
testcase_18 AC 256 ms
94,180 KB
testcase_19 AC 1,223 ms
94,352 KB
testcase_20 AC 197 ms
94,180 KB
testcase_21 AC 386 ms
94,180 KB
testcase_22 AC 1,461 ms
94,352 KB
testcase_23 AC 1,450 ms
94,356 KB
testcase_24 AC 1,450 ms
94,352 KB
testcase_25 AC 1,440 ms
94,356 KB
testcase_26 AC 1,451 ms
241,596 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (107 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;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var p = int.Parse(line[1]);
        var q = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, p, q, a);
    }
    static long[,] makeArray(int p)
    {
        var x = new int[] { 10, 9, 7, 5 };
        var res = new long[4, 2000001];
        for (int i = 0; i < 4; i++) res[i, 0] = 1L;
        for (int i = 1; i <= 2000000; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                res[j, i] = res[j, i - 1] * x[j];
                res[j, i] %= p;
            }
        }
        return res;
    }
    static void getAns(int n, int p, int q, int[] a)
    {
        var d = makeArray(p);
        Array.Sort(a);
        var c = 0;
        for (int i = 0; i < n - 3; i++)
        {
            for (int j = i + 1; j < n - 2; j++)
            {
                for (int k = j + 1; k < n - 1; k++)
                {
                    for (int L = k + 1; L < n; L++)
                    {
                        var ww = (d[0, a[i]] + d[1, a[j]] + d[2, a[k]] + d[3, a[L]]) % p;
                        if (ww == q) c++;
                    }
                }
            }
        }
        Console.WriteLine(c);
    }
}
0