結果
| 問題 |
No.1800 Random XOR
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-24 23:23:27 |
| 言語 | Scala(Beta) (3.6.2) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,344 bytes |
| コンパイル時間 | 15,574 ms |
| コンパイル使用メモリ | 280,740 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2025-02-19 23:26:16 |
| 合計ジャッジ時間 | 22,109 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 1 |
| other | -- * 14 |
ソースコード
import scala.collection.mutable
import scala.io.StdIn.*
import scala.math.min
import ModInt._
object ModInt:
opaque type ModInt = Long
extension (value: Long)
inline def asModInt(using inline mod: Int): ModInt = value % mod
extension (value: Int)
inline def asModInt(using inline mod: Int): ModInt = value % mod
trait Converter[T]:
inline def convert(value: T)(using inline mod: Int): ModInt
inline given Converter[Int] with
override inline def convert(value: Int)(using inline mod: Int) = value.asModInt
inline given Converter[Long] with
override inline def convert(value: Long)(using inline mod: Int) = value.asModInt
inline given Converter[ModInt] with
override inline def convert(value: ModInt)(using inline mod: Int) = value
extension (modInt: ModInt)
inline def asLong(using inline mod: Int): Long = (modInt + mod) % mod
inline def inverse(using inline mod: Int): ModInt = modInt.powMod(mod - 2)
inline def powMod(exp: Int)(using inline mod: Int): ModInt =
var result = 1L
var base = modInt
var e = exp
while e > 0 do
if (e & 1) == 1 then
result = result * base % mod
base = base * base % mod
e >>= 1
result
inline def powMod(exp: Long)(using inline mod: Int): ModInt =
var result = 1L
var base = modInt
var e = exp
while e > 0 do
if (e & 1) == 1 then
result = result * base % mod
base = base * base % mod
e >>= 1
result
extension [L: Converter, R: Converter] (left: L)
inline def +(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) + summon[Converter[R]].convert(right)).asModInt
inline def -(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) - summon[Converter[R]].convert(right)).asModInt
inline def *(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) * summon[Converter[R]].convert(right)).asModInt
inline def /(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) * summon[Converter[R]].convert(right).inverse).asModInt
@main def main =
inline given mod: Int = 1000000007
val Array(n, m) = readLine().split(' ').map(_.toLong)
val max = 2L.asModInt.powMod(m) - 1
val result = max / 2
println(result.asLong)