結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー 👑 箱星箱星
提出日時 2021-10-29 21:22:24
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,923 bytes
コンパイル時間 15,898 ms
コンパイル使用メモリ 443,276 KB
実行使用メモリ 50,360 KB
最終ジャッジ日時 2024-04-16 13:56:13
合計ジャッジ時間 31,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 305 ms
50,076 KB
testcase_02 AC 304 ms
50,028 KB
testcase_03 AC 308 ms
50,048 KB
testcase_04 AC 327 ms
50,128 KB
testcase_05 AC 319 ms
50,156 KB
testcase_06 AC 306 ms
49,988 KB
testcase_07 AC 299 ms
50,128 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 329 ms
50,228 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 307 ms
49,920 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 340 ms
50,048 KB
testcase_37 WA -
testcase_38 AC 296 ms
49,992 KB
testcase_39 AC 301 ms
50,016 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 297 ms
49,948 KB
testcase_45 AC 307 ms
50,008 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 302 ms
50,160 KB
testcase_49 AC 302 ms
49,972 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