結果
問題 | No.1463 Hungry Kanten |
ユーザー | bluemegane |
提出日時 | 2021-04-17 09:48:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 446 ms / 2,000 ms |
コード長 | 1,435 bytes |
コンパイル時間 | 2,428 ms |
コンパイル使用メモリ | 65,768 KB |
実行使用メモリ | 50,508 KB |
最終ジャッジ日時 | 2023-09-16 15:47:15 |
合計ジャッジ時間 | 6,190 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
22,528 KB |
testcase_01 | AC | 67 ms
24,608 KB |
testcase_02 | AC | 80 ms
29,388 KB |
testcase_03 | AC | 345 ms
28,556 KB |
testcase_04 | AC | 66 ms
22,516 KB |
testcase_05 | AC | 446 ms
50,508 KB |
testcase_06 | AC | 65 ms
22,572 KB |
testcase_07 | AC | 67 ms
24,636 KB |
testcase_08 | AC | 67 ms
22,396 KB |
testcase_09 | AC | 67 ms
20,460 KB |
testcase_10 | AC | 66 ms
22,520 KB |
testcase_11 | AC | 68 ms
24,548 KB |
testcase_12 | AC | 67 ms
22,564 KB |
testcase_13 | AC | 67 ms
22,436 KB |
testcase_14 | AC | 70 ms
22,436 KB |
testcase_15 | AC | 68 ms
22,524 KB |
testcase_16 | AC | 80 ms
27,640 KB |
testcase_17 | AC | 101 ms
31,020 KB |
testcase_18 | AC | 80 ms
27,368 KB |
testcase_19 | AC | 227 ms
41,220 KB |
testcase_20 | AC | 316 ms
49,392 KB |
testcase_21 | AC | 67 ms
24,556 KB |
ソースコード
using System.Numerics; using System.Collections.Generic; using System.Linq; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, long.Parse); getAn(n, k, a); } static void getAn(int n, int k, long[] a) { var hs = new HashSet<BigInteger>(); var imax = 1 << n; for (int i = 0; i < imax; i++) { if (countbit(i) >= k) { var s1 = 0L; BigInteger s2 = 1; for (int j = 0; j < n; j++) { if (((i >> j) & 1) == 1) { s1 += a[j]; s2 *= a[j]; } } hs.Add(s1); hs.Add(s2); } } Console.WriteLine(hs.Count()); } static int countbit(long bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (int)(bits & 0x0000ffff) + (int)(bits >> 16 & 0x0000ffff); } }