Posts [BOJ 백준] 15953번 상금 헌터 / C++
Post
Cancel

[BOJ 백준] 15953번 상금 헌터 / C++


Contents



문제


문제를 보시려면 링크를 클릭해주세요.


풀이


a와 b가 0이 아닐 경우, 등수에 해당하는 상금을 더해줬습니다.


소스 코드


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
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>

using namespace std;

int main(){
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	
	int A[]={1,2,3,4,5,6};
	int A_reward[]={500,300,200,50,30,10};
	int B[]={1,2,4,8,16};
	int B_reward[]={512,256,128,64,32};	
	
	cin >> N;
	for(int i=0; i<N; i++){
		int a,b;
		cin >> a >> b;
		int res=0;
		int rA=0,rB=0;
		
		
		for(int j=0; j<sizeof(A)/sizeof(A[0]); j++){
			rA+=A[j];
			if(a<=rA && a!=0){
				res+=A_reward[j];
				break;
			}
		}
		
		for(int j=0; j<sizeof(B)/sizeof(B[0]); j++){
			rB+=B[j];
			if(b<=rB && b!=0){
				res+=B_reward[j];
				break;	
			}			
		}
		
		cout << res*10000 <<"\n";
	}
	return 0; 
}



This post is licensed under CC BY 4.0 by the author.

[BOJ 백준] 1085번 직사각형에서 탈출 / C++

[BOJ 백준] 13458번 시험 감독 / C++

Comments powered by Disqus.