結果

問題 No.1463 Hungry Kanten
ユーザー face4face4
提出日時 2021-04-10 15:51:53
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,599 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 13,018 ms
コンパイル使用メモリ 426,760 KB
実行使用メモリ 104,144 KB
最終ジャッジ日時 2023-09-08 11:52:39
合計ジャッジ時間 25,930 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
52,464 KB
testcase_01 AC 284 ms
52,260 KB
testcase_02 AC 488 ms
62,060 KB
testcase_03 AC 1,217 ms
64,844 KB
testcase_04 AC 323 ms
53,148 KB
testcase_05 AC 1,599 ms
104,144 KB
testcase_06 AC 284 ms
52,868 KB
testcase_07 AC 285 ms
52,612 KB
testcase_08 AC 293 ms
52,864 KB
testcase_09 AC 291 ms
52,852 KB
testcase_10 AC 304 ms
52,588 KB
testcase_11 AC 309 ms
52,764 KB
testcase_12 AC 335 ms
55,408 KB
testcase_13 AC 329 ms
54,980 KB
testcase_14 AC 441 ms
60,904 KB
testcase_15 AC 422 ms
60,932 KB
testcase_16 AC 486 ms
61,916 KB
testcase_17 AC 650 ms
65,652 KB
testcase_18 AC 551 ms
60,616 KB
testcase_19 AC 946 ms
76,984 KB
testcase_20 AC 968 ms
79,360 KB
testcase_21 AC 312 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger
fun String.toBigInteger() = BigInteger.valueOf(this.toLong())

fun main(){
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toBigInteger()}

    val ints = mutableSetOf<BigInteger>()
    for(i in 1..(1 shl n)){
        val indexes = mutableSetOf<Int>()
        for(j in 0 until n){
            if(((i shr j) and 1) == 1)   indexes.add(j)
        }
        if(indexes.size < k)  continue
        ints.add(a.filterIndexed{index,  _ -> indexes.contains(index)}.reduce{s, t -> s*t})
        ints.add(a.filterIndexed{index, _ -> indexes.contains(index)}.reduce{s, t -> s.add(t)})
    }

    println(ints.size)
}
0