Submission #57219


ソースコード

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
26
27
28
29
30
31
32
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b;
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int c,d=0,e=0,f=0,g=1,h=0;
bool ans[600];
int i[100];
cin >>a;
memset(ans,false,sizeof(ans));
for(int n=0;n<a;n++) cin >>i[n];
for(int n=1;n<(1<<a);n++){
int p=0;
for(int m=0;m<a;m++){
if((n&(1<<m))!=0) p+=i[m];
}
ans[p]=true;
}
for(int n=1;n<600;n++){
if(ans[n]) cout <<n<<'\n';
}
return (0);
}

ステータス

項目 データ
問題 1221 - bit全探索(基本)
ユーザー名 ei1923
投稿日時 2019-12-12 15:39:59
言語 C++14
状態 Accepted
得点 1
ソースコード長 706 Byte
最大実行時間 75 ms
最大メモリ使用量 604 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 30 ms 604 KB
1
in02.text AC 27 ms 564 KB
1
in03.text AC 18 ms 524 KB
1
in04.text AC 15 ms 480 KB
1
in05.text AC 22 ms 568 KB
1
in06.text AC 33 ms 520 KB
1
in07.text AC 19 ms 476 KB
1
in08.text AC 75 ms 560 KB
1
in09.text AC 71 ms 508 KB
1
in10.text AC 63 ms 592 KB
1