結果
問題 | No.147 試験監督(2) |
ユーザー |
|
提出日時 | 2017-07-11 16:47:08 |
言語 | D (dmd 2.109.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,286 bytes |
コンパイル時間 | 1,406 ms |
コンパイル使用メモリ | 123,644 KB |
実行使用メモリ | 16,960 KB |
最終ジャッジ日時 | 2024-06-12 20:52:21 |
合計ジャッジ時間 | 8,146 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 3 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.string;immutable long MOD = 10^^9 + 7;long[][] matmul(long[][] m1, long[][] m2) {int n = m1.length.to!int;long[][] ret = new long[][](n, n);foreach (i; 0..n) foreach (j; 0..n) foreach (k; 0..n) {(ret[i][j] += m1[i][k] * m2[k][j] % MOD) %= MOD;}return ret;}long[][] matpow(long[][] m, long x) {int n = m.length.to!int;long[][] ret = new long[][](n, n);foreach (i; 0..n) ret[i][i] = 1;while (x) {if (x % 2) ret = matmul(ret, m);m = matmul(m, m);x /= 2;}return ret;}long powmod(long a, BigInt x) {long ret = 1;while (x) {if (x & 1) ret = ret * a % MOD;a = a * a % MOD;x /= 2;}return ret;}void main() {auto N = readln.chomp.to!long;long[][] hoge = [[1, 1], [1, 0]];long ans = 1;foreach (i; 0..N) {auto s = readln.split;auto C = s[0].to!long;auto D = s[1].to!BigInt;auto F = matpow(hoge, C+1)[0][0];F.writeln;ans = ans * powmod(F, D) % MOD;}ans.writeln;}