[백준 24768] Left Beehind (C#, C++) - soo:bak
작성일 :
문제 링크
설명
달콤한 꿀단지 수와 신 꿀단지 수가 주어질 때, 조건에 따라 결과를 출력하는 문제입니다. 입력은 0 0이 주어지면 종료됩니다.
접근법
두 꿀단지 수의 합이 13이면 특별한 메시지를 출력합니다. 그 외의 경우에는 달콤한 꿀단지가 더 많으면 대회에 가고, 신 꿀단지가 더 많으면 뒤처지며, 같으면 미정입니다.
각 조건을 순서대로 확인하여 해당하는 결과를 출력하면 됩니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
class Program {
static void Main() {
while (true) {
var line = Console.ReadLine();
if (line == null) break;
var parts = line.Split();
var x = int.Parse(parts[0]);
var y = int.Parse(parts[1]);
if (x == 0 && y == 0) break;
if (x + y == 13) Console.WriteLine("Never speak again.");
else if (x > y) Console.WriteLine("To the convention.");
else if (x < y) Console.WriteLine("Left beehind.");
else Console.WriteLine("Undecided.");
}
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x, y;
while (cin >> x >> y) {
if (x == 0 && y == 0) break;
if (x + y == 13) cout << "Never speak again.\n";
else if (x > y) cout << "To the convention.\n";
else if (x < y) cout << "Left beehind.\n";
else cout << "Undecided.\n";
}
return 0;
}