結果

問題 No.308 素数は通れません
ユーザー firiexpfiriexp
提出日時 2020-03-28 15:24:10
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 334 ms / 1,000 ms
コード長 1,744 bytes
コンパイル時間 16,012 ms
コンパイル使用メモリ 429,164 KB
実行使用メモリ 53,936 KB
最終ジャッジ日時 2023-08-30 17:51:40
合計ジャッジ時間 46,243 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 249 ms
50,216 KB
testcase_01 AC 253 ms
50,248 KB
testcase_02 AC 264 ms
53,760 KB
testcase_03 AC 263 ms
53,712 KB
testcase_04 AC 264 ms
53,784 KB
testcase_05 AC 263 ms
53,936 KB
testcase_06 AC 266 ms
53,588 KB
testcase_07 AC 266 ms
53,728 KB
testcase_08 AC 264 ms
53,880 KB
testcase_09 AC 264 ms
53,736 KB
testcase_10 AC 264 ms
53,712 KB
testcase_11 AC 278 ms
53,932 KB
testcase_12 AC 266 ms
53,744 KB
testcase_13 AC 266 ms
53,744 KB
testcase_14 AC 266 ms
53,888 KB
testcase_15 AC 251 ms
50,344 KB
testcase_16 AC 253 ms
50,236 KB
testcase_17 AC 252 ms
50,616 KB
testcase_18 AC 259 ms
50,296 KB
testcase_19 AC 247 ms
50,240 KB
testcase_20 AC 249 ms
50,532 KB
testcase_21 AC 256 ms
50,180 KB
testcase_22 AC 249 ms
50,256 KB
testcase_23 AC 248 ms
50,124 KB
testcase_24 AC 250 ms
50,292 KB
testcase_25 AC 259 ms
50,296 KB
testcase_26 AC 259 ms
50,852 KB
testcase_27 AC 253 ms
50,296 KB
testcase_28 AC 252 ms
50,124 KB
testcase_29 AC 254 ms
50,292 KB
testcase_30 AC 246 ms
50,428 KB
testcase_31 AC 249 ms
50,260 KB
testcase_32 AC 263 ms
50,372 KB
testcase_33 AC 250 ms
50,212 KB
testcase_34 AC 259 ms
50,332 KB
testcase_35 AC 255 ms
50,536 KB
testcase_36 AC 252 ms
50,224 KB
testcase_37 AC 251 ms
50,224 KB
testcase_38 AC 252 ms
50,768 KB
testcase_39 AC 255 ms
50,428 KB
testcase_40 AC 251 ms
50,384 KB
testcase_41 AC 254 ms
50,184 KB
testcase_42 AC 252 ms
50,372 KB
testcase_43 AC 252 ms
50,304 KB
testcase_44 AC 251 ms
50,324 KB
testcase_45 AC 254 ms
50,240 KB
testcase_46 AC 254 ms
50,268 KB
testcase_47 AC 253 ms
50,168 KB
testcase_48 AC 250 ms
50,208 KB
testcase_49 AC 267 ms
50,556 KB
testcase_50 AC 254 ms
50,348 KB
testcase_51 AC 252 ms
50,252 KB
testcase_52 AC 251 ms
50,552 KB
testcase_53 AC 251 ms
50,392 KB
testcase_54 AC 261 ms
50,432 KB
testcase_55 AC 263 ms
50,364 KB
testcase_56 AC 272 ms
50,468 KB
testcase_57 AC 253 ms
50,244 KB
testcase_58 AC 250 ms
50,596 KB
testcase_59 AC 252 ms
50,332 KB
testcase_60 AC 252 ms
50,644 KB
testcase_61 AC 261 ms
50,344 KB
testcase_62 AC 251 ms
50,268 KB
testcase_63 AC 252 ms
50,332 KB
testcase_64 AC 252 ms
50,296 KB
testcase_65 AC 254 ms
50,432 KB
testcase_66 AC 253 ms
50,164 KB
testcase_67 AC 253 ms
50,144 KB
testcase_68 AC 258 ms
50,264 KB
testcase_69 AC 251 ms
50,248 KB
testcase_70 AC 256 ms
50,264 KB
testcase_71 AC 269 ms
50,324 KB
testcase_72 AC 256 ms
50,448 KB
testcase_73 AC 253 ms
50,240 KB
testcase_74 AC 256 ms
50,404 KB
testcase_75 AC 252 ms
50,196 KB
testcase_76 AC 265 ms
50,340 KB
testcase_77 AC 263 ms
50,604 KB
testcase_78 AC 265 ms
50,372 KB
testcase_79 AC 268 ms
50,472 KB
testcase_80 AC 271 ms
50,620 KB
testcase_81 AC 273 ms
50,536 KB
testcase_82 AC 268 ms
50,316 KB
testcase_83 AC 268 ms
50,416 KB
testcase_84 AC 276 ms
50,492 KB
testcase_85 AC 269 ms
50,408 KB
testcase_86 AC 274 ms
50,828 KB
testcase_87 AC 276 ms
50,584 KB
testcase_88 AC 271 ms
50,568 KB
testcase_89 AC 273 ms
50,356 KB
testcase_90 AC 275 ms
50,600 KB
testcase_91 AC 302 ms
50,904 KB
testcase_92 AC 329 ms
51,024 KB
testcase_93 AC 310 ms
51,120 KB
testcase_94 AC 311 ms
50,936 KB
testcase_95 AC 311 ms
50,956 KB
testcase_96 AC 253 ms
50,168 KB
testcase_97 AC 250 ms
50,208 KB
testcase_98 AC 262 ms
50,348 KB
testcase_99 AC 258 ms
50,200 KB
testcase_100 AC 256 ms
50,452 KB
testcase_101 AC 306 ms
50,956 KB
testcase_102 AC 334 ms
50,968 KB
testcase_103 AC 275 ms
50,496 KB
testcase_104 AC 253 ms
50,460 KB
testcase_105 AC 257 ms
50,744 KB
testcase_106 AC 257 ms
50,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:32:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.io.PrintWriter
import java.lang.Math.abs
import java.math.BigDecimal
import java.math.BigInteger
import java.util.*
import kotlin.math.max
import kotlin.math.min

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out
@JvmField val cin = INPUT.bufferedReader()
fun readLine(): String? = cin.readLine()
fun readLn() = cin.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(cin.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }
@JvmField val cout = PrintWriter(OUTPUT, false)

fun main(args: Array<String>) {
    val t = read().toBigInteger()
    if(t <= 25.toBigInteger()){
        val tt = t.toInt()
        cout.println( when(tt) {
            4 -> 3
            6 -> 5
            in arrayOf(8, 9, 10, 15, 16, 22) -> 7
            12 -> 11
            14 -> 13
            20 -> 19
            21 -> 19
            24 -> 23
            25 -> 23
            else -> 8
        })
    }else {
        cout.println(if(t.subtract(8.toBigInteger()).isProbablePrime(100) && t.rem(8.toBigInteger()) == BigInteger.ONE) 14 else 8)
    }
    cout.flush()
}
0