結果
問題 |
No.1253 雀見椪
|
ユーザー |
|
提出日時 | 2025-03-08 20:11:02 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 221 ms / 2,000 ms |
コード長 | 1,499 bytes |
コンパイル時間 | 8,499 ms |
コンパイル使用メモリ | 172,672 KB |
実行使用メモリ | 188,184 KB |
最終ジャッジ日時 | 2025-03-08 20:11:14 |
合計ジャッジ時間 | 12,198 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (120 ミリ秒)。 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 long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new long[t]; var mod = 1_000_000_007; for (var u = 0; u < t; ++u) { var c = NList; var (n, ag, bg, ac, bc, ap, bp) = (c[0], c[1], c[2], c[3], c[4], c[5], c[6]); var dg = ag * Exp(bg, mod - 2, mod) % mod; var dc = ac * Exp(bc, mod - 2, mod) % mod; var dp = ap * Exp(bp, mod - 2, mod) % mod; var allg = Exp(dg, n, mod); var allc = Exp(dc, n, mod); var allp = Exp(dp, n, mod); var j = (Exp(dg + dc, n, mod) + Exp(dc + dp, n, mod) + Exp(dp + dg, n, mod) - allg * 2 - allc * 2 - allp * 2 + (long)mod * 6) % mod; ans[u] = (1 - j + mod) % mod; } WriteLine(string.Join("\n", 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; } }