結果

問題 No.1464 Number Conversion
ユーザー face4face4
提出日時 2021-04-07 20:25:26
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 15,716 ms
コンパイル使用メモリ 417,152 KB
実行使用メモリ 54,920 KB
最終ジャッジ日時 2023-09-05 04:11:22
合計ジャッジ時間 26,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 329 ms
53,668 KB
testcase_01 AC 336 ms
53,784 KB
testcase_02 AC 339 ms
54,320 KB
testcase_03 AC 339 ms
53,784 KB
testcase_04 WA -
testcase_05 AC 334 ms
53,696 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 333 ms
53,652 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 336 ms
54,232 KB
testcase_22 WA -
testcase_23 AC 336 ms
53,780 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 341 ms
54,168 KB
testcase_28 AC 337 ms
53,968 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-2) else 1
    val p = gcd(s, b)
    s /= p
    b /= p
    println("%d/%d".format(s, b))
}
0