Submission #74381
ソースコード
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全探索(基本) |
ユーザー名 | ei2314 |
投稿日時 | 2023-07-10 17:26:42 |
言語 | C++11 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 489 Byte |
最大実行時間 | 106 ms |
最大メモリ使用量 | 704 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.text | AC | 18 ms | 604 KB |
1
|
in02.text | AC | 16 ms | 704 KB |
1
|
in03.text | AC | 27 ms | 544 KB |
1
|
in04.text | AC | 21 ms | 640 KB |
1
|
in05.text | AC | 29 ms | 468 KB |
1
|
in06.text | AC | 27 ms | 552 KB |
1
|
in07.text | AC | 18 ms | 512 KB |
1
|
in08.text | AC | 98 ms | 480 KB |
1
|
in09.text | AC | 96 ms | 568 KB |
1
|
in10.text | AC | 106 ms | 528 KB |
1
|