結果

問題 No.2709 1975 Powers
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-09 23:31:38
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 869 ms / 2,000 ms
コード長 1,534 bytes
コンパイル時間 8,361 ms
コンパイル使用メモリ 168,748 KB
実行使用メモリ 185,924 KB
最終ジャッジ日時 2024-04-09 23:32:05
合計ジャッジ時間 19,127 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
30,080 KB
testcase_01 AC 56 ms
30,080 KB
testcase_02 AC 62 ms
30,720 KB
testcase_03 AC 487 ms
30,848 KB
testcase_04 AC 678 ms
30,824 KB
testcase_05 AC 553 ms
30,720 KB
testcase_06 AC 195 ms
30,976 KB
testcase_07 AC 55 ms
30,208 KB
testcase_08 AC 171 ms
30,576 KB
testcase_09 AC 476 ms
30,848 KB
testcase_10 AC 55 ms
30,056 KB
testcase_11 AC 67 ms
30,720 KB
testcase_12 AC 86 ms
30,592 KB
testcase_13 AC 542 ms
31,104 KB
testcase_14 AC 114 ms
30,848 KB
testcase_15 AC 123 ms
30,720 KB
testcase_16 AC 386 ms
30,976 KB
testcase_17 AC 58 ms
30,592 KB
testcase_18 AC 98 ms
30,848 KB
testcase_19 AC 721 ms
30,720 KB
testcase_20 AC 61 ms
30,720 KB
testcase_21 AC 169 ms
32,776 KB
testcase_22 AC 788 ms
30,848 KB
testcase_23 AC 791 ms
30,720 KB
testcase_24 AC 836 ms
30,976 KB
testcase_25 AC 787 ms
30,700 KB
testcase_26 AC 869 ms
185,924 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var x = NList;
        var (n, p, q) = (x[0], x[1], x[2]);
        var y = NList;
        Array.Sort(y);
        var i10 = new long[n];
        var i9 = new long[n];
        var i7 = new long[n];
        var i5 = new long[n];
        for (var i = 0; i < n; ++i)
        {
            i10[i] = Exp(10, y[i], p);
            i9[i] = Exp(9, y[i], p);
            i7[i] = Exp(7, y[i], p);
            i5[i] = Exp(5, y[i], p);
        }
        var ans = 0;
        for (var a = 0; a < n; ++a) for (var b = a + 1; b < n; ++b) for (var c = b + 1; c < n; ++c) for (var d = c + 1; d < n; ++d)
        {
            if ((i10[a] + i9[b] + i7[c] + i5[d]) % p == q) ++ans;
        }
        WriteLine(ans);
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0