結果

問題 No.312 置換処理
コンテスト
ユーザー 826814741_6
提出日時 2019-01-09 23:55:25
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 290 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,320 ms
コンパイル使用メモリ 434,556 KB
実行使用メモリ 51,052 KB
最終ジャッジ日時 2026-05-10 11:39:48
合計ジャッジ時間 20,915 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import kotlin.math.*

fun g(n: Long): Long = floor(sqrt(n.toDouble())).toLong()

fun f(m: Long, n: Long): Long {
    for (i in 3..m) if (n%i==0L) return i
    return if (n!=4L&&n%2==0L) n/2 else n
}

fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    println(f(g(n),n))
}
0