結果

問題 No.1663 Maximum Remainder
ユーザー 👑 箱
提出日時 2021-09-03 21:21:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 15,946 ms
コンパイル使用メモリ 421,288 KB
実行使用メモリ 54,692 KB
最終ジャッジ日時 2023-08-21 19:18:59
合計ジャッジ時間 21,693 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
54,516 KB
testcase_01 AC 276 ms
54,396 KB
testcase_02 AC 268 ms
54,472 KB
testcase_03 AC 268 ms
54,564 KB
testcase_04 AC 270 ms
52,520 KB
testcase_05 AC 273 ms
54,692 KB
testcase_06 AC 270 ms
54,564 KB
testcase_07 AC 272 ms
54,496 KB
testcase_08 AC 269 ms
52,564 KB
testcase_09 AC 270 ms
54,424 KB
testcase_10 AC 267 ms
52,840 KB
testcase_11 AC 269 ms
52,516 KB
testcase_12 AC 267 ms
54,448 KB
testcase_13 AC 267 ms
52,756 KB
testcase_14 AC 267 ms
52,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val a = nextInt()
    val b = nextInt()
    val c = nextInt()
    val d = nextInt()
    val m = nextInt()
    var max = 0
    for (x in a..b) {
        for (y in c..d) {
            max = max(max, (x + y) % m)
        }
    }
    println(max)
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", 1.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