結果

問題 No.1463 Hungry Kanten
コンテスト
ユーザー face4
提出日時 2021-04-10 15:51:53
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 899 ms / 2,000 ms
+ 218µs
コード長 685 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,201 ms
コンパイル使用メモリ 507,764 KB
実行使用メモリ 131,092 KB
最終ジャッジ日時 2026-07-12 09:06:03
合計ジャッジ時間 19,009 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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