結果

問題 No.2709 1975 Powers
ユーザー bluemeganebluemegane
提出日時 2024-04-04 15:42:33
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,701 bytes
コンパイル時間 9,851 ms
コンパイル使用メモリ 158,772 KB
実行使用メモリ 39,608 KB
最終ジャッジ日時 2024-04-04 15:42:48
合計ジャッジ時間 14,215 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
35,748 KB
testcase_01 AC 68 ms
39,096 KB
testcase_02 AC 140 ms
32,676 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
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.Collections.Generic;
using System.Numerics;
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 void getAns(int n, int p, int q, int[] a)
    {
        var xx = (long)BigInteger.ModPow(7, 128, 17);
        
        Array.Sort(a);
        var d10 = new Dictionary<int, long>();
        var d9 = new Dictionary<int, long>();
        var d7 = new Dictionary<int, long>();
        var d5 = new Dictionary<int, long>();
        foreach (var x in a)
        {
            d10[x] = (long)BigInteger.ModPow(10, x, p);
            d9[x] = (long)BigInteger.ModPow(9, x, p);
            d7[x] = (long)BigInteger.ModPow(7, x, p);
            d5[x] = (long)BigInteger.ModPow(5, x, p);
        }
        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 w = d10[a[i]];
                        w += d9[a[j]];
                        w %= p;
                        w += d7[a[k]];
                        w %= p;
                        w += d5[a[L]];
                        w %= p;
                        if (w == q) c++;
                    }
                }
            }
        }
        Console.WriteLine(c);
    }
}
0