結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-09-08 09:24:04 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,244 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 66,788 KB |
| 最終ジャッジ日時 | 2024-11-14 19:10:40 |
| 合計ジャッジ時間 | 1,364 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(38, 14) Error: type mismatch Expression: <n [1] n: int Expected one of (first mismatch at [position]): [1] proc `<`(x, y: bool): bool [1] proc `<`(x, y: char): bool [1] proc `<`(x, y: float): bool [1] proc `<`(x, y: float32): bool [1] proc `<`(x, y: int16): bool [1] proc `<`(x, y: int32): bool [1] proc `<`(x, y: int8): bool [1] proc `<`(x, y: pointer): bool [1] proc `<`(x, y: string): bool [1] proc `<`(x, y: uint): bool [1] proc `<`(x, y: uint16): bool [1] proc `<`(x, y: uint32): bool [1] proc `<`(x, y: uint64): bool [1] proc `<`(x, y: uint8): bool [1] proc `<`[Enum: enum](x, y: Enum): bool [1] proc `<`[T: tuple](x, y: T): bool [1] proc `<`[T](x, y: ptr T): bool [1] proc `<`[T](x, y: ref T): bool [1] proc `<`[T](x, y: set[T]): bool [2] proc `<`(x, y: int): bool [2] proc `<`(x, y: int64): bool
ソースコード
import strutils, sequtils
const MOD = int(1e9) + 7
proc matmul(a: var seq[seq[int]], b: var seq[seq[int]]): seq[seq[int]] =
result = @[@[0, 0], @[0, 0]]
result[0][0] = (a[0][0]*b[0][0] + a[0][1]*b[1][0]) mod MOD
result[0][1] = (a[0][0]*b[0][1] + a[0][1]*b[1][1]) mod MOD
result[1][0] = (a[1][0]*b[0][0] + a[1][1]*b[1][0]) mod MOD
result[1][1] = (a[1][0]*b[0][1] + a[1][1]*b[1][1]) mod MOD
proc matpow(a: var seq[seq[int]], n: var int): seq[seq[int]] =
result = @[@[1, 0], @[0, 1]]
while n > 0:
if (n and 1) == 1:
result = matmul(result, a)
a = matmul(a, a)
n = n shr 1
proc bigint2modint(bignum: string, md: int): int =
result = 0
for c in bignum:
result = (result * 10 + (c.ord - '0'.ord)) mod md
if result == 0:
result = md - 1
proc mod_pow(a: var int, n: var int, md: int): int =
result = 1
while n > 0:
if (n and 1) == 1: result = result * a mod md
a = a * a mod md
n = n shr 1
var
n = stdin.readLine.parseInt
res = 1
for i in 0.. <n:
var
cd = stdin.readLine.split
c = cd[0].parseInt + 1
d = cd[1].bigint2modint(MOD - 1)
mat = @[@[1, 1], @[1, 0]]
powered = matpow(mat, c)
z = mod_pow(powered[0][0], d, MOD)
res = res * z mod MOD
echo res