結果
問題 | 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.mutableimport scala.io.StdIn.*import scala.math.minimport ModInt._object ModInt:opaque type ModInt = Longextension (value: Long)inline def asModInt(using inline mod: Int): ModInt = value % modextension (value: Int)inline def asModInt(using inline mod: Int): ModInt = value % modtrait Converter[T]:inline def convert(value: T)(using inline mod: Int): ModIntinline given Converter[Int] withoverride inline def convert(value: Int)(using inline mod: Int) = value.asModIntinline given Converter[Long] withoverride inline def convert(value: Long)(using inline mod: Int) = value.asModIntinline given Converter[ModInt] withoverride inline def convert(value: ModInt)(using inline mod: Int) = valueextension (modInt: ModInt)inline def asLong(using inline mod: Int): Long = (modInt + mod) % modinline def inverse(using inline mod: Int): ModInt = modInt.powMod(mod - 2)inline def powMod(exp: Int)(using inline mod: Int): ModInt =var result = 1Lvar base = modIntvar e = expwhile e > 0 doif (e & 1) == 1 thenresult = result * base % modbase = base * base % mode >>= 1resultinline def powMod(exp: Long)(using inline mod: Int): ModInt =var result = 1Lvar base = modIntvar e = expwhile e > 0 doif (e & 1) == 1 thenresult = result * base % modbase = base * base % mode >>= 1resultextension [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)).asModIntinline def -(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) - summon[Converter[R]].convert(right)).asModIntinline def *(right: R)(using inline mod: Int): ModInt = (summon[Converter[L]].convert(left) * summon[Converter[R]].convert(right)).asModIntinline 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 = 1000000007val Array(n, m) = readLine().split(' ').map(_.toLong)val max = 2L.asModInt.powMod(m) - 1val result = max / 2println(result.asLong)