結果
問題 |
No.2709 1975 Powers
|
ユーザー |
![]() |
提出日時 | 2024-04-04 10:07:02 |
言語 | C# (.NET 8.0.404) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,464 bytes |
コンパイル時間 | 7,164 ms |
コンパイル使用メモリ | 166,992 KB |
実行使用メモリ | 45,768 KB |
最終ジャッジ日時 | 2024-10-01 00:19:15 |
合計ジャッジ時間 | 10,969 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 23 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (97 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/
ソースコード
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) { 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]] + d9[a[j]] + d7[a[k]] + d5[a[L]]) % p; if (w == q) c++; } } } } Console.WriteLine(c); } }