結果

問題 No.2709 1975 Powers
ユーザー bluemeganebluemegane
提出日時 2024-04-04 16:06:43
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,535 bytes
コンパイル時間 9,463 ms
コンパイル使用メモリ 158,504 KB
実行使用メモリ 101,160 KB
最終ジャッジ日時 2024-04-04 16:07:16
合計ジャッジ時間 33,084 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
97,632 KB
testcase_01 AC 189 ms
100,980 KB
testcase_02 AC 214 ms
94,184 KB
testcase_03 AC 1,657 ms
94,228 KB
testcase_04 TLE -
testcase_05 AC 1,791 ms
94,356 KB
testcase_06 AC 703 ms
94,352 KB
testcase_07 AC 191 ms
94,180 KB
testcase_08 AC 660 ms
94,180 KB
testcase_09 AC 1,793 ms
94,352 KB
testcase_10 AC 202 ms
94,180 KB
testcase_11 AC 234 ms
94,180 KB
testcase_12 AC 323 ms
94,184 KB
testcase_13 AC 1,865 ms
94,228 KB
testcase_14 AC 412 ms
94,180 KB
testcase_15 AC 466 ms
94,180 KB
testcase_16 AC 1,464 ms
94,352 KB
testcase_17 AC 196 ms
94,184 KB
testcase_18 AC 342 ms
94,184 KB
testcase_19 TLE -
testcase_20 AC 205 ms
94,180 KB
testcase_21 AC 632 ms
94,184 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (98 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]]) % p;
                        ww += d[2, a[k]];
                        ww %= p;
                        ww += d[3, a[L]];
                        ww %= p;
                        if (ww == q) c++;
                    }
                }
            }
        }
        Console.WriteLine(c);
    }
}
0