結果

問題 No.2709 1975 Powers
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-09 23:28:24
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,510 bytes
コンパイル時間 8,004 ms
コンパイル使用メモリ 166,412 KB
実行使用メモリ 184,972 KB
最終ジャッジ日時 2024-04-09 23:28:52
合計ジャッジ時間 18,780 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
30,080 KB
testcase_01 AC 55 ms
29,824 KB
testcase_02 AC 62 ms
30,592 KB
testcase_03 AC 497 ms
30,720 KB
testcase_04 AC 681 ms
30,720 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 57 ms
29,952 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 57 ms
30,080 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 116 ms
30,592 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 790 ms
30,720 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 790 ms
30,592 KB
testcase_26 AC 802 ms
184,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (98 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;
        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