結果

問題 No.16 累乗の加算
ユーザー koba-e964koba-e964
提出日時 2015-12-05 02:52:15
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,031 ms / 5,000 ms
コード長 660 bytes
コンパイル時間 10,306 ms
コンパイル使用メモリ 265,780 KB
実行使用メモリ 64,128 KB
最終ジャッジ日時 2023-09-11 22:21:07
合計ジャッジ時間 25,838 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 954 ms
61,992 KB
testcase_01 AC 988 ms
63,204 KB
testcase_02 AC 996 ms
63,232 KB
testcase_03 AC 1,004 ms
63,080 KB
testcase_04 AC 1,015 ms
63,156 KB
testcase_05 AC 1,018 ms
63,428 KB
testcase_06 AC 1,031 ms
63,168 KB
testcase_07 AC 1,021 ms
63,112 KB
testcase_08 AC 1,018 ms
63,448 KB
testcase_09 AC 1,031 ms
63,160 KB
testcase_10 AC 1,017 ms
63,472 KB
testcase_11 AC 1,021 ms
63,196 KB
testcase_12 AC 1,019 ms
63,252 KB
testcase_13 AC 1,021 ms
64,128 KB
権限があれば一括ダウンロードができます

ソースコード

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
      e /= 2
    }
    sum
  }
  val x,n = sc.nextInt
  val a = Array.fill(n)(pow(x,sc.nextLong))
  println(a.sum % mod)
}
0