結果
問題 | No.1463 Hungry Kanten |
ユーザー |
|
提出日時 | 2021-03-08 13:20:53 |
言語 | Java (openjdk 23) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 776 bytes |
コンパイル時間 | 2,436 ms |
コンパイル使用メモリ | 75,776 KB |
実行使用メモリ | 66,672 KB |
最終ジャッジ日時 | 2024-12-23 23:16:06 |
合計ジャッジ時間 | 7,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 WA * 3 |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); long k=sc.nextLong(); long[] a=new long[n]; for(int i=0;i<n;i++){ a[i] = sc.nextLong(); } Set<Long> target = new HashSet<Long>(); for (long i = 0; i < 1 << n; i++) { long sum=0; long cnt=0; long pro=1; for (int j = 0; j < n; j++) { if ((1 & i >> j) == 1) { sum+=a[j]; cnt+=1; pro*=a[j]; } } if(cnt>=k){ target.add(sum); target.add(pro); } } System.out.println((target.size())); sc.close(); } }