結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー 👑 箱
提出日時 2021-10-29 21:23:29
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 1,923 bytes
コンパイル時間 14,855 ms
コンパイル使用メモリ 438,984 KB
実行使用メモリ 50,188 KB
最終ジャッジ日時 2024-04-16 13:58:10
合計ジャッジ時間 31,879 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 295 ms
50,136 KB
testcase_01 AC 296 ms
50,032 KB
testcase_02 AC 297 ms
49,812 KB
testcase_03 AC 302 ms
50,016 KB
testcase_04 AC 321 ms
50,060 KB
testcase_05 AC 313 ms
49,896 KB
testcase_06 AC 298 ms
49,816 KB
testcase_07 AC 305 ms
50,068 KB
testcase_08 AC 321 ms
49,972 KB
testcase_09 AC 306 ms
49,896 KB
testcase_10 AC 318 ms
50,052 KB
testcase_11 AC 300 ms
50,024 KB
testcase_12 AC 303 ms
49,988 KB
testcase_13 AC 297 ms
49,944 KB
testcase_14 AC 297 ms
49,996 KB
testcase_15 AC 332 ms
50,124 KB
testcase_16 AC 316 ms
50,108 KB
testcase_17 AC 336 ms
50,004 KB
testcase_18 AC 326 ms
50,136 KB
testcase_19 AC 327 ms
49,960 KB
testcase_20 AC 315 ms
50,100 KB
testcase_21 AC 324 ms
50,140 KB
testcase_22 AC 317 ms
50,112 KB
testcase_23 AC 332 ms
50,016 KB
testcase_24 AC 298 ms
49,884 KB
testcase_25 AC 321 ms
50,188 KB
testcase_26 AC 317 ms
49,964 KB
testcase_27 AC 299 ms
50,020 KB
testcase_28 AC 324 ms
50,064 KB
testcase_29 AC 322 ms
50,016 KB
testcase_30 AC 329 ms
50,096 KB
testcase_31 AC 315 ms
50,096 KB
testcase_32 AC 317 ms
50,116 KB
testcase_33 AC 300 ms
49,932 KB
testcase_34 AC 297 ms
49,860 KB
testcase_35 AC 302 ms
49,884 KB
testcase_36 AC 336 ms
49,948 KB
testcase_37 AC 294 ms
49,868 KB
testcase_38 AC 303 ms
49,916 KB
testcase_39 AC 306 ms
50,056 KB
testcase_40 AC 298 ms
49,916 KB
testcase_41 AC 292 ms
50,000 KB
testcase_42 AC 295 ms
49,848 KB
testcase_43 AC 294 ms
50,036 KB
testcase_44 AC 293 ms
49,860 KB
testcase_45 AC 303 ms
50,144 KB
testcase_46 AC 297 ms
49,788 KB
testcase_47 AC 298 ms
49,940 KB
testcase_48 AC 298 ms
50,036 KB
testcase_49 AC 293 ms
49,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val x = nextLong()
    val a = nextLong()
    val y = nextLong()
    val b = nextLong()
    // region prime factorization
    var number = x
    var divisor = 2L
    val pf = mutableMapOf<Long, Long>()
    while (divisor * divisor <= number) {
        var count = 0
        while (number % divisor == 0L) {
            number /= divisor
            count++
        }
        if (count > 0) {
            pf[divisor] = count * a
        }
        divisor++
    }
    if (number > 1) pf[number] = a
    // endregion
    // region prime factorization
    number = y
    divisor = 2L
    val pf2 = mutableMapOf<Long, Long>()
    while (divisor * divisor <= number) {
        var count = 0
        while (number % divisor == 0L) {
            number /= divisor
            count++
        }
        if (count > 0) {
            pf2[divisor] = count * b
        }
        divisor++
    }
    if (number > 1) pf2[number] = b
    // endregion
    for (k in pf2.keys) {
        if (!pf.containsKey(k)) {
            pf[k] = 0
        }
    }
    if (pf.keys.all { pf[it]!! >= pf2[it] ?: 0 }) {
        println("Yes")
    } else {
        println("No")
    }
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0