結果

問題 No.542 1円玉と5円玉
ユーザー Shawn stayCShawn stayC
提出日時 2020-06-20 13:37:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 1,652 ms
コンパイル使用メモリ 171,632 KB
実行使用メモリ 140,528 KB
最終ジャッジ日時 2023-09-16 17:23:53
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,752 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

int main(){
	int a,b; cin>>a>>b;
	vector<int> v;
	rep(i,a) v.push_back(1);
	rep(i,b) v.push_back(5);
	int n=v.size();
		
	vector<int> ans;
	for(int bit=0; bit<(1<<n); bit++){
		int sum=0;
		for(int i=0; i<n; i++){
			if(bit &(1<<i)) sum+=v[i];
		}
		ans.push_back(sum);
	}
	sort(all(ans));
	UNIQUE(ans);
	ans.erase(remove(ans.begin(),ans.end(), 0),ans.end());
	for(auto x:ans) cout << x << endl;
}
0