結果

問題 No.16 累乗の加算
ユーザー koba-e964koba-e964
提出日時 2015-12-05 02:51:56
言語 Scala(Beta)
(3.4.0)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 9,651 ms
コンパイル使用メモリ 260,752 KB
実行使用メモリ 70,088 KB
最終ジャッジ日時 2023-09-11 22:20:08
合計ジャッジ時間 22,393 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * Reference: http://lizan.asia/blog/2012/12/11/scala-competitive/
 */

object Main extends App {
  import java.{util => ju}
  import scala.annotation._
  import scala.collection._
  import scala.collection.{mutable => mu}
  import scala.collection.JavaConverters._
  import scala.math._

  val sc = new ju.Scanner(System.in)
  val mod : Long = 1000003
  def pow(a:Long, b:Long)={
    var sum : Long= 1
    var cur : Long= a
    var e = b
    while (e > 0) {
      if (e % 2 == 1) { sum *= cur; sum %= mod}
      cur = cur * cur % mod
    }
    sum
  }
  val x,n = sc.nextInt
  val a = Array.fill(n)(pow(x,sc.nextLong))
  println(a.sum % mod)
}
0