結果

問題 No.1463 Hungry Kanten
ユーザー rhincodon66rhincodon66
提出日時 2021-04-02 21:45:14
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 685 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 15,216 ms
コンパイル使用メモリ 428,184 KB
実行使用メモリ 93,400 KB
最終ジャッジ日時 2023-08-25 14:55:08
合計ジャッジ時間 20,103 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
53,080 KB
testcase_01 AC 242 ms
52,948 KB
testcase_02 AC 359 ms
56,940 KB
testcase_03 AC 422 ms
57,028 KB
testcase_04 AC 273 ms
55,348 KB
testcase_05 AC 685 ms
93,400 KB
testcase_06 AC 243 ms
52,908 KB
testcase_07 AC 244 ms
52,904 KB
testcase_08 AC 244 ms
53,004 KB
testcase_09 AC 242 ms
52,924 KB
testcase_10 AC 249 ms
53,036 KB
testcase_11 AC 247 ms
53,072 KB
testcase_12 AC 247 ms
52,904 KB
testcase_13 AC 264 ms
55,596 KB
testcase_14 AC 292 ms
55,912 KB
testcase_15 AC 284 ms
56,176 KB
testcase_16 AC 310 ms
56,452 KB
testcase_17 AC 389 ms
58,500 KB
testcase_18 AC 336 ms
56,220 KB
testcase_19 AC 474 ms
71,044 KB
testcase_20 AC 605 ms
72,872 KB
testcase_21 AC 246 ms
53,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:7:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

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