結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー face4face4
提出日時 2021-04-11 15:01:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 15,355 ms
コンパイル使用メモリ 418,088 KB
実行使用メモリ 50,508 KB
最終ジャッジ日時 2023-09-09 17:24:25
合計ジャッジ時間 21,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
50,176 KB
testcase_01 AC 272 ms
50,128 KB
testcase_02 AC 275 ms
50,264 KB
testcase_03 AC 275 ms
50,264 KB
testcase_04 AC 274 ms
50,112 KB
testcase_05 AC 269 ms
50,200 KB
testcase_06 AC 274 ms
50,184 KB
testcase_07 AC 271 ms
50,056 KB
testcase_08 AC 271 ms
50,228 KB
testcase_09 AC 274 ms
50,264 KB
testcase_10 AC 271 ms
50,316 KB
testcase_11 AC 270 ms
50,240 KB
testcase_12 AC 272 ms
50,168 KB
testcase_13 AC 276 ms
50,144 KB
testcase_14 AC 271 ms
50,108 KB
testcase_15 AC 275 ms
50,508 KB
testcase_16 AC 283 ms
50,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.math.max
import kotlin.math.sqrt

fun main() {
    val n = readLine()!!.toInt()
    var maxsq = 1
    val sq : (Int) -> Int = {sqrt(it.toDouble()).toInt()}
    val isSq : (Int) -> Boolean = {sq(it)*sq(it)==it}
    for(i in 1..sqrt(n.toDouble()).toInt()){
        if(n%i != 0)    continue
        if(isSq(n/i)) maxsq = max(maxsq,n/i)
        else if(isSq(i))    maxsq = max(maxsq, i)
    }
    println("${sq(maxsq)} ${n/maxsq}")
}
0