[문제 링크] : https://www.acmicpc.net/problem/28702
#include <iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string A, B, C;
cin >> A >> B >> C;
if(C[0] >= 48 && C[0] <= 57){
int x = stoi(C) + 1;
if(x % 3 == 0){
if(x % 5 == 0){
cout << "FizzBuzz";
}
else{
cout << "Fizz";
}
}
else if(x % 5 == 0){
cout << "Buzz";
}
else{
cout << x;
}
}
else if(B[0] >= 48 && B[0] <= 57){
int x = stoi(B) + 2;
if(x % 3 == 0){
if(x % 5 == 0){
cout << "FizzBuzz";
}
else{
cout << "Fizz";
}
}
else if(x % 5 == 0){
cout << "Buzz";
}
else{
cout << x;
}
}
else if(A[0] >= 48 && A[0] <= 57){
int x = stoi(A) + 3;
if(x % 3 == 0){
if(x % 5 == 0){
cout << "FizzBuzz";
}
else{
cout << "Fizz";
}
}
else if(x % 5 == 0){
cout << "Buzz";
}
else{
cout << x;
}
}
cout << "\n";
return 0;
}
'알고리즘' 카테고리의 다른 글
[알고리즘] 백준 17614 - 369 (C++) (0) | 2024.10.04 |
---|---|
[알고리즘] 백준 14720 - 우유 축제 (C++) (0) | 2024.10.03 |
[알고리즘] 백준 15700 - 타일 채우기 4 (C++) (0) | 2024.10.01 |
[알고리즘] 백준 8545 - Zadanie próbne (C++) (0) | 2024.09.30 |
[알고리즘] 백준 10801 - 카드게임 (C++) (0) | 2024.09.29 |