結果

問題 No.1010 折って重ねて
ユーザー mikhailmikhail
提出日時 2020-03-20 21:57:04
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 2,905 bytes
コンパイル時間 21,116 ms
コンパイル使用メモリ 435,504 KB
実行使用メモリ 57,252 KB
最終ジャッジ日時 2023-08-21 16:26:22
合計ジャッジ時間 37,010 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 303 ms
56,908 KB
testcase_01 AC 308 ms
56,736 KB
testcase_02 AC 306 ms
56,780 KB
testcase_03 AC 306 ms
56,828 KB
testcase_04 AC 310 ms
56,952 KB
testcase_05 AC 304 ms
56,708 KB
testcase_06 AC 305 ms
56,808 KB
testcase_07 AC 304 ms
56,900 KB
testcase_08 AC 310 ms
56,848 KB
testcase_09 AC 303 ms
56,792 KB
testcase_10 AC 306 ms
56,924 KB
testcase_11 AC 305 ms
56,892 KB
testcase_12 AC 308 ms
57,020 KB
testcase_13 AC 306 ms
56,784 KB
testcase_14 AC 303 ms
57,116 KB
testcase_15 AC 310 ms
57,052 KB
testcase_16 AC 314 ms
56,932 KB
testcase_17 AC 309 ms
56,844 KB
testcase_18 AC 310 ms
56,868 KB
testcase_19 AC 311 ms
56,716 KB
testcase_20 AC 305 ms
57,132 KB
testcase_21 AC 307 ms
56,844 KB
testcase_22 AC 308 ms
56,856 KB
testcase_23 AC 309 ms
56,864 KB
testcase_24 AC 313 ms
56,812 KB
testcase_25 AC 307 ms
56,852 KB
testcase_26 AC 312 ms
56,780 KB
testcase_27 AC 307 ms
56,788 KB
testcase_28 AC 314 ms
56,800 KB
testcase_29 AC 312 ms
56,796 KB
testcase_30 AC 309 ms
56,768 KB
testcase_31 AC 308 ms
56,864 KB
testcase_32 AC 305 ms
56,704 KB
testcase_33 AC 308 ms
56,900 KB
testcase_34 AC 311 ms
57,252 KB
testcase_35 AC 307 ms
57,156 KB
testcase_36 AC 309 ms
57,112 KB
testcase_37 AC 313 ms
56,880 KB
testcase_38 AC 315 ms
56,768 KB
testcase_39 AC 312 ms
56,884 KB
testcase_40 AC 301 ms
56,852 KB
testcase_41 AC 308 ms
56,784 KB
testcase_42 AC 309 ms
56,980 KB
testcase_43 AC 309 ms
56,888 KB
testcase_44 AC 304 ms
56,860 KB
testcase_45 AC 304 ms
56,756 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