반응형
https://www.acmicpc.net/problem/4562
4562번: No Brainer
For each data set, there will be exactly one line of output. This line will be "MMM BRAINS" if the number of brains the zombie eats is greater than or equal to the number of brains the zombie requires to stay alive. Otherwise, the line will be "NO BRAINS".
www.acmicpc.net
표준 입출력, while문, if문을 사용해보는 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
1. 뇌를 먹은 개수 a, 생존에 필요하며 먹어야 할 뇌의 개수 b, 테스트 케이스의 개수 t를 선언 후 t를 입력해줍니다. 2. t만큼 a,b를 입력해줍니다.
📔 정답출력
1. a >= b인 경우 : MMM BRAINS\n를 출력해줍니다.
2. 그 외 : NO BRAINS\n을 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int a, b, t;
int main(){
cin >> t;
while(t--){
cin >> a >> b;
if(a >= b) cout << "MMM BRAINS\n";
else cout << "NO BRAINS\n";
}
}
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 백준(BOJ) 6812 : Good times (2) | 2021.12.03 |
---|---|
(C++) - 백준(BOJ) 4619 : 루트 (0) | 2021.12.02 |
(C++) - 백준(BOJ) 4084 : Viva la Diferencia (0) | 2021.12.01 |
(C++) - 백준(BOJ) 2997 : 네 번째 수 (0) | 2021.11.28 |
(C++) - 백준(BOJ) 2975 : Transactions (0) | 2021.11.27 |