結果

問題 No.300 平方数
ユーザー koba-e964koba-e964
提出日時 2022-02-22 16:33:23
言語 Scala(Beta)
(3.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 651 bytes
コンパイル時間 11,070 ms
コンパイル使用メモリ 248,336 KB
実行使用メモリ 65,364 KB
最終ジャッジ日時 2023-11-25 13:35:27
合計ジャッジ時間 59,565 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 987 ms
65,288 KB
testcase_01 AC 981 ms
65,292 KB
testcase_02 AC 984 ms
65,304 KB
testcase_03 AC 980 ms
65,308 KB
testcase_04 AC 978 ms
65,300 KB
testcase_05 AC 990 ms
65,312 KB
testcase_06 AC 992 ms
65,296 KB
testcase_07 TLE -
testcase_08 AC 986 ms
65,300 KB
testcase_09 AC 983 ms
65,300 KB
testcase_10 AC 975 ms
65,304 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 998 ms
65,304 KB
testcase_14 AC 984 ms
65,304 KB
testcase_15 AC 979 ms
65,320 KB
testcase_16 AC 983 ms
65,316 KB
testcase_17 AC 998 ms
65,308 KB
testcase_18 AC 978 ms
65,296 KB
testcase_19 AC 975 ms
65,300 KB
testcase_20 AC 977 ms
65,364 KB
testcase_21 AC 978 ms
65,292 KB
testcase_22 AC 991 ms
65,320 KB
testcase_23 AC 998 ms
65,300 KB
testcase_24 AC 996 ms
65,292 KB
testcase_25 TLE -
testcase_26 AC 981 ms
65,296 KB
testcase_27 AC 990 ms
65,296 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 AC 994 ms
65,208 KB
testcase_31 AC 988 ms
65,292 KB
testcase_32 AC 978 ms
65,288 KB
testcase_33 AC 978 ms
65,332 KB
testcase_34 TLE -
testcase_35 TLE -
testcase_36 AC 991 ms
65,240 KB
testcase_37 AC 993 ms
65,236 KB
testcase_38 AC 979 ms
65,308 KB
testcase_39 TLE -
testcase_40 AC 999 ms
65,280 KB
testcase_41 AC 986 ms
65,276 KB
testcase_42 AC 985 ms
65,304 KB
testcase_43 AC 994 ms
65,224 KB
testcase_44 AC 981 ms
65,288 KB
testcase_45 AC 998 ms
65,312 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)
  def t(v : Long , p : Long, acc : Long) : Long = {
    if (v < p * p) {
      return acc * v
    }
    var cnt = 0
    var x = v
    while (x % p == 0) {
       cnt = 1 - cnt
        x /= p
    }
    var nacc = acc
    if (cnt == 1) nacc *= p
    return t(x, p + 1, nacc)
  }
  val q = sc.nextLong
  println(t(q, 2, 1))
}
0