結果
問題 | No.2324 Two Countries within UEC |
ユーザー |
|
提出日時 | 2023-10-18 00:15:12 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,280 bytes |
コンパイル時間 | 8,262 ms |
コンパイル使用メモリ | 166,852 KB |
実行使用メモリ | 187,204 KB |
最終ジャッジ日時 | 2024-09-17 21:19:19 |
合計ジャッジ時間 | 15,390 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 WA * 11 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /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; 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(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m, p, q) = (c[0], c[1], c[2], c[3]); var ans = new int[q]; for (var u = 0; u < q; ++u) { c = NList; ans[u] = Country(m, c[0], c[1], p); } WriteLine(string.Join("\n", ans)); } static int Country(int m, int x, int f, int p) { var revx = Exp(x, p - 2, p); var ex = (int)(f * revx % p); if (ex > m) return 0; return (m - ex) / p + (ex > 0 ? 1 : 0); } static int GCD(int a, int b) { if (a < b) return GCD(b, a); if (a % b == 0) return b; return GCD(b, a % b); } static long Exp(long n, long k, int mod) { if (k == 0) return 1; if (k == 1) return n % mod; var half = Exp(n, k / 2, mod); var result = (half * half) % mod; return ((k % 2) == 0) ? result : ((result * n) % mod); } }