結果
問題 | No.428 小数から逃げる夢 |
ユーザー | nobigomu |
提出日時 | 2018-06-07 12:43:55 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 324 ms / 1,000 ms |
コード長 | 1,960 bytes |
コンパイル時間 | 14,318 ms |
コンパイル使用メモリ | 441,100 KB |
実行使用メモリ | 51,300 KB |
最終ジャッジ日時 | 2024-11-20 16:19:21 |
合計ジャッジ時間 | 48,661 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 315 ms
50,980 KB |
testcase_01 | AC | 313 ms
50,980 KB |
testcase_02 | AC | 313 ms
51,232 KB |
testcase_03 | AC | 310 ms
51,268 KB |
testcase_04 | AC | 315 ms
51,088 KB |
testcase_05 | AC | 312 ms
51,168 KB |
testcase_06 | AC | 313 ms
51,128 KB |
testcase_07 | AC | 312 ms
51,260 KB |
testcase_08 | AC | 312 ms
50,948 KB |
testcase_09 | AC | 307 ms
51,212 KB |
testcase_10 | AC | 306 ms
50,916 KB |
testcase_11 | AC | 312 ms
51,204 KB |
testcase_12 | AC | 315 ms
51,160 KB |
testcase_13 | AC | 311 ms
50,984 KB |
testcase_14 | AC | 312 ms
51,092 KB |
testcase_15 | AC | 311 ms
50,992 KB |
testcase_16 | AC | 310 ms
50,864 KB |
testcase_17 | AC | 316 ms
50,852 KB |
testcase_18 | AC | 311 ms
51,196 KB |
testcase_19 | AC | 312 ms
50,992 KB |
testcase_20 | AC | 315 ms
51,028 KB |
testcase_21 | AC | 308 ms
50,968 KB |
testcase_22 | AC | 312 ms
50,964 KB |
testcase_23 | AC | 313 ms
51,024 KB |
testcase_24 | AC | 314 ms
50,860 KB |
testcase_25 | AC | 312 ms
50,988 KB |
testcase_26 | AC | 315 ms
51,168 KB |
testcase_27 | AC | 312 ms
51,016 KB |
testcase_28 | AC | 315 ms
51,112 KB |
testcase_29 | AC | 313 ms
51,032 KB |
testcase_30 | AC | 312 ms
51,216 KB |
testcase_31 | AC | 314 ms
51,272 KB |
testcase_32 | AC | 310 ms
50,984 KB |
testcase_33 | AC | 310 ms
51,268 KB |
testcase_34 | AC | 310 ms
51,260 KB |
testcase_35 | AC | 316 ms
50,832 KB |
testcase_36 | AC | 316 ms
51,132 KB |
testcase_37 | AC | 315 ms
51,084 KB |
testcase_38 | AC | 317 ms
51,060 KB |
testcase_39 | AC | 316 ms
51,240 KB |
testcase_40 | AC | 315 ms
50,848 KB |
testcase_41 | AC | 313 ms
51,128 KB |
testcase_42 | AC | 314 ms
50,952 KB |
testcase_43 | AC | 314 ms
51,092 KB |
testcase_44 | AC | 317 ms
50,912 KB |
testcase_45 | AC | 324 ms
51,100 KB |
testcase_46 | AC | 315 ms
51,116 KB |
testcase_47 | AC | 312 ms
51,144 KB |
testcase_48 | AC | 311 ms
50,968 KB |
testcase_49 | AC | 316 ms
51,300 KB |
testcase_50 | AC | 316 ms
51,072 KB |
testcase_51 | AC | 312 ms
51,172 KB |
testcase_52 | AC | 305 ms
51,268 KB |
testcase_53 | AC | 311 ms
50,856 KB |
testcase_54 | AC | 310 ms
50,836 KB |
testcase_55 | AC | 309 ms
50,860 KB |
testcase_56 | AC | 313 ms
51,272 KB |
testcase_57 | AC | 311 ms
50,996 KB |
testcase_58 | AC | 313 ms
51,020 KB |
testcase_59 | AC | 310 ms
51,092 KB |
testcase_60 | AC | 313 ms
51,160 KB |
testcase_61 | AC | 313 ms
50,972 KB |
testcase_62 | AC | 314 ms
50,956 KB |
testcase_63 | AC | 309 ms
51,200 KB |
testcase_64 | AC | 306 ms
50,864 KB |
testcase_65 | AC | 312 ms
50,856 KB |
testcase_66 | AC | 309 ms
50,964 KB |
testcase_67 | AC | 313 ms
51,072 KB |
testcase_68 | AC | 314 ms
50,964 KB |
testcase_69 | AC | 314 ms
50,876 KB |
testcase_70 | AC | 316 ms
51,124 KB |
testcase_71 | AC | 312 ms
51,276 KB |
testcase_72 | AC | 313 ms
51,008 KB |
testcase_73 | AC | 311 ms
50,988 KB |
testcase_74 | AC | 311 ms
51,060 KB |
testcase_75 | AC | 312 ms
50,960 KB |
testcase_76 | AC | 313 ms
51,228 KB |
testcase_77 | AC | 312 ms
51,000 KB |
testcase_78 | AC | 312 ms
51,160 KB |
testcase_79 | AC | 308 ms
50,872 KB |
testcase_80 | AC | 313 ms
51,024 KB |
testcase_81 | AC | 312 ms
50,864 KB |
testcase_82 | AC | 311 ms
51,212 KB |
testcase_83 | AC | 310 ms
51,164 KB |
testcase_84 | AC | 312 ms
51,012 KB |
testcase_85 | AC | 310 ms
50,832 KB |
testcase_86 | AC | 310 ms
51,196 KB |
testcase_87 | AC | 311 ms
50,956 KB |
testcase_88 | AC | 310 ms
51,128 KB |
testcase_89 | AC | 311 ms
51,064 KB |
testcase_90 | AC | 313 ms
51,056 KB |
testcase_91 | AC | 311 ms
50,920 KB |
testcase_92 | AC | 315 ms
51,088 KB |
testcase_93 | AC | 312 ms
51,056 KB |
testcase_94 | AC | 312 ms
51,024 KB |
testcase_95 | AC | 314 ms
51,088 KB |
testcase_96 | AC | 316 ms
50,916 KB |
testcase_97 | AC | 315 ms
51,092 KB |
testcase_98 | AC | 313 ms
50,852 KB |
testcase_99 | AC | 313 ms
51,076 KB |
コンパイルメッセージ
Main.kt:50:10: warning: parameter 'args' is never used fun main(args: Array<String>) { ^
ソースコード
val D = "1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991" fun f(n:Int): String { tailrec fun iter(i: Int, c: Int, sb: StringBuilder) { if (i>=0) { val t = n*D.slice(i..i).toInt()+c sb.insert(0,(t%10).toString()) return iter(i-1, t/10, sb) } else { if (c!=0) { sb.insert(0,c.toString()) } } } val sb = StringBuilder(D.length+2) val t = n*D.slice(D.length-1..D.length-1).toInt() sb.insert(0,(t%10).toString()) iter(D.length-2,t/10,sb) if (sb.length==D.length) sb.insert(0,"0.") else sb.insert(sb.length-D.length,".") return sb.toString() } fun g(m: Int, n: Int): String { fun f(a: Int, b: Int, c: Int) = if (a%10+b%10+c>9) 1 else 0 tailrec fun iter(i: Int, c: Int, c1: Int, c2: Int, t2: Int, sb: StringBuilder) { if (i>=0) { val t = D.slice(i..i).toInt() val t1 = n*t+c1 sb.insert(0,((t2+t1+c)%10).toString()) iter(i-1, f(t2,t1,c), t1/10, (m*t+c2)/10, m*t+c2, sb) } else { sb.insert(0,(t2+c1+c).toString()) } } val sb = StringBuilder(D.length+3) var t = D.slice(D.length-1..D.length-1).toInt() var t1 = n*t val t2 = m*t val c1 = t1/10 val c2 = t2/10 sb.insert(0,(t1%10).toString()) t = D.slice(D.length-2..D.length-2).toInt() t1 = n*t+c1 sb.insert(0,((t1+t2)%10).toString()) iter(D.length-3, f(t2,t1,0), t1/10, (m*t+c2)/10, m*t+c2, sb) sb.insert(sb.length-D.length,".") return sb.toString() } fun main(args: Array<String>) { val s = readLine()!! when (s.length) { 1 -> println(f(s.toInt())) 2 -> println(g(s.slice(0..0).toInt(), s.slice(1..1).toInt())) else -> println(D.slice(0..1).plus(".").plus(D.slice(2..D.length-1))) } }