Submission #74394
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int a[n]; for ( int i=0;i<n;i++){ cin >> a[i]; } set< int > ans; for ( int bit=1;bit<(1<<n);bit++){ int s=0; for ( int i=0;i<n;i++){ if (bit&(1<<i)){ s+=a[i]; } } ans.insert(s); } for (auto itr =ans.begin();itr !=ans.end();itr++){ cout << *itr << "\n" ; } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1221 - bit全探索(基本) |
ユーザー名 | ei2312 |
投稿日時 | 2023-07-10 17:34:35 |
言語 | C++17 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 491 Byte |
最大実行時間 | 103 ms |
最大メモリ使用量 | 600 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.text | AC | 22 ms | 600 KB |
1
|
in02.text | AC | 23 ms | 444 KB |
1
|
in03.text | AC | 20 ms | 416 KB |
1
|
in04.text | AC | 29 ms | 508 KB |
1
|
in05.text | AC | 19 ms | 468 KB |
1
|
in06.text | AC | 23 ms | 556 KB |
1
|
in07.text | AC | 18 ms | 520 KB |
1
|
in08.text | AC | 99 ms | 480 KB |
1
|
in09.text | AC | 93 ms | 564 KB |
1
|
in10.text | AC | 103 ms | 516 KB |
1
|