結果

問題 No.1464 Number Conversion
ユーザー face4face4
提出日時 2021-04-07 20:29:36
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 14,320 ms
コンパイル使用メモリ 418,776 KB
実行使用メモリ 54,656 KB
最終ジャッジ日時 2023-09-05 04:17:41
合計ジャッジ時間 26,509 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
54,328 KB
testcase_01 AC 337 ms
53,960 KB
testcase_02 AC 340 ms
53,868 KB
testcase_03 AC 335 ms
54,164 KB
testcase_04 AC 337 ms
54,044 KB
testcase_05 AC 338 ms
53,992 KB
testcase_06 AC 341 ms
54,228 KB
testcase_07 AC 337 ms
54,204 KB
testcase_08 AC 346 ms
54,468 KB
testcase_09 AC 343 ms
54,240 KB
testcase_10 AC 341 ms
54,472 KB
testcase_11 AC 338 ms
54,392 KB
testcase_12 AC 338 ms
54,616 KB
testcase_13 AC 338 ms
54,292 KB
testcase_14 AC 347 ms
54,656 KB
testcase_15 AC 336 ms
54,240 KB
testcase_16 AC 341 ms
53,832 KB
testcase_17 AC 339 ms
54,192 KB
testcase_18 AC 338 ms
54,028 KB
testcase_19 AC 339 ms
53,972 KB
testcase_20 AC 336 ms
53,952 KB
testcase_21 AC 338 ms
54,016 KB
testcase_22 AC 342 ms
53,876 KB
testcase_23 AC 334 ms
53,976 KB
testcase_24 AC 342 ms
53,872 KB
testcase_25 AC 344 ms
54,012 KB
testcase_26 AC 342 ms
54,312 KB
testcase_27 AC 340 ms
54,184 KB
testcase_28 AC 335 ms
54,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fun gcd(a: Long, b: Long) : Long{
    return if(b == 0L) a else gcd(b, a%b)
}

fun power(n: Int) : Long{
    var ret = 1L
    repeat(n){
        ret *= 10
    }
    return ret
}

fun main(){
    val x = readLine()!!
    var s = x.replace(".","").toLong()
    var b = if(x.contains(".")) power(x.length-x.indexOf('.')-1) else 1
    val p = gcd(s, b)
    s /= p
    b /= p
    println("%d/%d".format(s, b))
}
0