結果

問題 No.36 素数が嫌い!
ユーザー くわいくわい
提出日時 2015-11-16 12:38:27
言語 Scala(Beta)
(3.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 680 bytes
コンパイル時間 5,117 ms
コンパイル使用メモリ 222,128 KB
最終ジャッジ日時 2024-04-27 02:15:43
合計ジャッジ時間 5,536 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
-- [E040] Syntax Error: Main.scala:26:32 ---------------------------------------
26 |  def main(args: Array[String]) {
   |                                ^
   |                                '=' expected, but '{' found
1 error found

ソースコード

diff #

import scala.annotation.tailrec
import scala.io.StdIn

object Problem036 {

  // 素因数分解
  def primeFactorization(n: Long): List[Long] = {
    @tailrec
    def factor(n: Long, div: Long, result: List[Long]): List[Long] = {
      if (n < div * div) {
        n :: result
      } else if (n % div == 0) {
        factor(n / div, div, div :: result)
      } else {
        factor(n, div + 1, result)
      }
    }
    factor(n, 2, Nil)
  }

  def proc(n: Long): String = {
    val pf = primeFactorization(n)
    if (pf.length >= 3) "YES" else "NO"
  }

  def main(args: Array[String]) {
    val n = StdIn.readLong()
    val result: String = proc(n)
    println(result)
  }
}
0