結果

問題 No.1010 折って重ねて
ユーザー mikhailmikhail
提出日時 2020-03-20 21:57:04
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 2,905 bytes
コンパイル時間 13,536 ms
コンパイル使用メモリ 459,124 KB
実行使用メモリ 60,432 KB
最終ジャッジ日時 2024-12-15 05:39:34
合計ジャッジ時間 28,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
60,268 KB
testcase_01 AC 310 ms
60,344 KB
testcase_02 AC 299 ms
60,196 KB
testcase_03 AC 287 ms
60,292 KB
testcase_04 AC 296 ms
60,212 KB
testcase_05 AC 283 ms
60,300 KB
testcase_06 AC 279 ms
60,432 KB
testcase_07 AC 280 ms
60,176 KB
testcase_08 AC 300 ms
60,320 KB
testcase_09 AC 283 ms
60,296 KB
testcase_10 AC 283 ms
60,220 KB
testcase_11 AC 288 ms
60,272 KB
testcase_12 AC 295 ms
60,296 KB
testcase_13 AC 293 ms
60,188 KB
testcase_14 AC 285 ms
60,196 KB
testcase_15 AC 297 ms
60,232 KB
testcase_16 AC 296 ms
60,196 KB
testcase_17 AC 283 ms
60,312 KB
testcase_18 AC 286 ms
60,360 KB
testcase_19 AC 283 ms
60,184 KB
testcase_20 AC 305 ms
60,344 KB
testcase_21 AC 285 ms
60,208 KB
testcase_22 AC 281 ms
60,428 KB
testcase_23 AC 280 ms
60,276 KB
testcase_24 AC 302 ms
60,204 KB
testcase_25 AC 286 ms
60,288 KB
testcase_26 AC 282 ms
60,284 KB
testcase_27 AC 296 ms
60,184 KB
testcase_28 AC 288 ms
60,296 KB
testcase_29 AC 291 ms
60,224 KB
testcase_30 AC 289 ms
60,276 KB
testcase_31 AC 294 ms
60,324 KB
testcase_32 AC 292 ms
60,264 KB
testcase_33 AC 292 ms
60,212 KB
testcase_34 AC 284 ms
60,152 KB
testcase_35 AC 285 ms
60,212 KB
testcase_36 AC 290 ms
60,292 KB
testcase_37 AC 279 ms
60,180 KB
testcase_38 AC 282 ms
60,304 KB
testcase_39 AC 290 ms
60,304 KB
testcase_40 AC 287 ms
60,176 KB
testcase_41 AC 288 ms
60,300 KB
testcase_42 AC 283 ms
60,280 KB
testcase_43 AC 283 ms
60,280 KB
testcase_44 AC 282 ms
60,432 KB
testcase_45 AC 279 ms
60,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:9:10: warning: parameter 'args' is never used
fun main(args: Array<String>){
         ^
Main.kt:61:129: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
                                                                                                                                ^
Main.kt:62:124: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
                                                                                                                           ^

ソースコード

diff #

import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)
val MOD = 1000000007L
val INF = 2147483647
val LINF = 9223372036854775807L

fun main(args: Array<String>){
    solve()
    pw.flush()    
}

fun solve(){
    var (x, y, h) = nextLongList()
    x *= 1000
    y *= 1000
    var a = min(x, y).toDouble()
    var b = max(x, y).toDouble()
    var c = h.toDouble()
    var ans = 0
    while(a > c){
        a /= 2.0
        c *= 2
        ans++
    }
    while(b > c){
        b /= 2.0
        c *= 2
        ans++
    }
    println(ans)

}


// Print
fun println(v: String){
    pw.println(v)
}
fun print(v: String){
    pw.print(v)
}

// Read
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextLongList() = next().split(" ").map{ it.toLong() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextAryln(n: Int) = Array(n){ next() }
fun nextIntAryln(n: Int) = IntArray(n){ nextInt() }
fun nextLongAryln(n: Int) = LongArray(n){ nextLong() }
fun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }

// Math
fun abs(n: Long) : Long = Math.abs(n)
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
fun prime(from: Long, to: Long = from) : List<Long>{
    return (from..to).filter{ i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all{ j -> i % j != 0L}
    }
}
fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))
fun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b
fun modpow(a: Long, n: Long, p:Long = MOD) : Long {
    var res = 1L
    var ar = a
    var nr = n
    while(nr > 0){
        if((nr and 1) == 1L) res = res * ar % p
        ar = ar * ar % p
        nr = nr shr 1
    }
    return res
}
fun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)
fun ncr(n: Long, r: Long) : Long {
    var a = 1L
    var b = 1L
    for (i in 1..r) {
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    }
    return modinv(b, MOD) * a % MOD
}

class Combination(val max: Int){
    val fac = LongArray(max)
    val finv = LongArray(max)
    val inv = LongArray(max)
    val p = MOD.toInt()
    fun init(){
        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for (i in 2 until max) {
            fac[i] = fac[i - 1] * i % p
            inv[i] = p - inv[p % i] * (p / i) % p;
            finv[i] = finv[i - 1] * inv[i] % p
        }
    }
    fun com(n: Int, r: Int) : Long = if(n < r || (n < 0 || r < 0)) 0 else fac[n] * (finv[r] * finv[n - r] % p) % p
}
0