結果

問題 No.312 置換処理
コンテスト
ユーザー koba-e964
提出日時 2015-12-05 02:26:09
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,091 ms
コンパイル使用メモリ 266,228 KB
実行使用メモリ 65,808 KB
最終ジャッジ日時 2026-03-09 14:28:29
合計ジャッジ時間 31,555 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/*
 * 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)
  @tailrec
  def  calc(t:Long, n : Long) : Long={
    () match {
     case  _ if n % t == 0 => t
      case _ if 2 * n < t * t => if (n >= 6 && n % 2 == 0) n / 2 else n
      case _ => calc(t + 1, n)
    }
  }
  val n = sc.nextLong
  println(calc(3, n))
}
0