結果

問題 No.1463 Hungry Kanten
ユーザー face4face4
提出日時 2021-04-10 15:51:05
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,653 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 15,409 ms
コンパイル使用メモリ 419,908 KB
実行使用メモリ 104,112 KB
最終ジャッジ日時 2023-09-08 11:51:22
合計ジャッジ時間 29,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 292 ms
52,404 KB
testcase_01 AC 289 ms
52,536 KB
testcase_02 AC 503 ms
63,484 KB
testcase_03 AC 1,026 ms
64,728 KB
testcase_04 AC 327 ms
52,992 KB
testcase_05 AC 1,653 ms
104,112 KB
testcase_06 AC 290 ms
52,832 KB
testcase_07 AC 289 ms
52,436 KB
testcase_08 AC 294 ms
52,836 KB
testcase_09 AC 316 ms
52,832 KB
testcase_10 AC 315 ms
52,564 KB
testcase_11 AC 309 ms
52,980 KB
testcase_12 AC 327 ms
54,956 KB
testcase_13 AC 319 ms
54,888 KB
testcase_14 AC 431 ms
61,196 KB
testcase_15 AC 418 ms
60,824 KB
testcase_16 AC 493 ms
61,744 KB
testcase_17 AC 667 ms
65,980 KB
testcase_18 AC 482 ms
58,512 KB
testcase_19 AC 982 ms
75,424 KB
testcase_20 AC 991 ms
78,820 KB
testcase_21 AC 314 ms
52,928 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..n-1){
            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