구현(Implementation)
백준 4435번: 중간계 전쟁
cepiloth
2018. 7. 27. 13:18
반응형
https://www.acmicpc.net/problem/4435
1. 문제
룩업테이블 이용한 적산 문제
2. 알고리즘
키워드 - 구현, 배열
3. 코드
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include <iostream> #include <sstream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <list> #include <queue> #include <deque> #include <map> #include <set> #include <stack> #include <math.h> using namespace std; #define MAX_SIZE 100 #define INF 0x7fffffff #define CENDL "\n" #define ll long long char gundal[6] = {1, 2, 3, 3, 4, 10}; char sauron[7] = {1, 2, 2, 2, 3, 5, 10}; int main() { cin.tie(0); std::ios::sync_with_stdio(false); int n; cin >> n; for(int k=0; k<n; k++) { unsigned int sum_a = 0; for(int i=0; i<6; i++) { int d; cin >> d; if(d > 0) sum_a += gundal[i] * d; } unsigned int sum_b = 0; for(int i=0; i<7; i++) { int d; cin >> d; if(d > 0) sum_b += sauron[i] * d; } cout << "Battle " << k+1 << ": "; if (sum_a == sum_b) { cout << "No victor on this battle field" << CENDL; } else if(sum_a > sum_b) { cout << "Good triumphs over Evil" << CENDL; } else if(sum_a < sum_b) { cout << "Evil eradicates all trace of Good" << CENDL; } } return 0; } | cs |
반응형