結果

問題 No.1463 Hungry Kanten
ユーザー rhincodon66
提出日時 2021-04-02 21:45:14
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 773 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 11,773 ms
コンパイル使用メモリ 473,988 KB
実行使用メモリ 122,656 KB
最終ジャッジ日時 2025-06-20 01:32:44
合計ジャッジ時間 24,432 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger
import java.util.*
import javax.swing.plaf.SeparatorUI
import kotlin.math.ceil
import java.util.Queue as Queue1

fun main(args:Array<String>) {
    solve()
}

fun solve(){
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}.toIntArray()
    val a = readLine()!!.split(" ").map{it.toInt()}.toIntArray()
    val s = HashSet<BigInteger>()
    for(mask in 0 until (1 shl n)){
        var sum = 0
        var sum2 = 1.toBigInteger()
        var cnt = 0
        for(i in 0 until n){
            if((mask shr i) and 1 == 1){
                sum += a[i]
                sum2 *= a[i].toBigInteger()
                cnt++
            }
        }
        if(cnt >= k){
            s.add(sum.toBigInteger())
            s.add(sum2)
        }
    }
    println(s.size)
}

0