結果
問題 | No.1258 コインゲーム |
ユーザー |
![]() |
提出日時 | 2020-10-16 22:25:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 622 ms / 2,000 ms |
コード長 | 773 bytes |
コンパイル時間 | 328 ms |
コンパイル使用メモリ | 82,272 KB |
実行使用メモリ | 78,884 KB |
最終ジャッジ日時 | 2024-07-20 22:30:16 |
合計ジャッジ時間 | 24,250 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
s = int(input())mod = 10**9+7for _ in range(s):n,m,x = map(int, input().split())if m%2 == 0:a = (pow(m+1, n, mod)-pow(m-1, n, mod))*pow(2, mod-2, mod)if n%2 == 0:if x == 0:ans = a+pow(m-1, n, mod)else:ans = aelse:if x == 0:ans = aelse:ans = a+pow(m-1, n, mod)else:a = (pow(m+1, n, mod)-pow(m-1, n, mod))*pow(2, mod-2, mod)if n%2 == 0:if x == 0:ans = a+pow(m-1, n, mod)else:ans = aelse:if x == 0:ans = aelse:ans = a+pow(m-1, n, mod)ans %= modprint(ans)