結果
問題 | No.673 カブトムシ |
ユーザー | 6soukiti29 |
提出日時 | 2018-04-14 00:16:54 |
言語 | Nim (2.0.2) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 961 bytes |
コンパイル時間 | 2,977 ms |
コンパイル使用メモリ | 69,000 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-12 18:13:09 |
合計ジャッジ時間 | 3,833 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 1 ms
4,376 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
import sequtils,strutils,math var B,C,D,ans,p : int64 M : int64 = 1_000_000_007 (B, C, D) = stdin.readline.split.map(parseBiggestInt) if C == 1: echo(((B mod M) * (D mod M)) mod M) quit() proc powInt(n : int64, m : int64, k = 1_000_000_007):int64 = if m == 0: return 1 elif m == 1: return (n mod k) var n2 = n mod k if (m mod 2) == 0: return powInt((n2 * n2) mod k,m div 2, k) mod k else: return (powInt((n2 * n2) mod k,m div 2, k) * n2) mod k proc inv_mod(a : int64):int64 = var b,x,u,q,t : int64 a2 = a b = M x = 1 u = 0 while b > 0: q = a2 div b t = u u = x - q * u x = t t = b b = a2 - q * b a2 = t if x < 0: x += M return x ans = B mod M ans = (ans * (C mod M)) mod M p = powInt(C, D) - 1 if p < 0: p += M ans = (ans * p) mod M ans = (ans * inv_mod(C - 1)) mod M echo ans