結果
| 問題 |
No.1463 Hungry Kanten
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-10 15:51:05 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 1,326 ms / 2,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 11,285 ms |
| コンパイル使用メモリ | 466,688 KB |
| 実行使用メモリ | 133,924 KB |
| 最終ジャッジ日時 | 2025-06-20 01:36:45 |
| 合計ジャッジ時間 | 26,520 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
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)
}