문제 링크입니다: www.acmicpc.net/problem/20499
20499번: Darius님 한타 안 함?
그가 「진짜」이면 gosu, 「가짜」이면 hasu를 출력한다.
www.acmicpc.net
간단한 문자열 처리 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
string KDA; | |
cin >> KDA; | |
size_t pos = KDA.find('/', 0); | |
vector<int> slashIdxs; | |
while (pos != string::npos) | |
{ | |
slashIdxs.push_back(pos); | |
pos = KDA.find('/', pos + 1); | |
} | |
int K = stoi(KDA.substr(0, slashIdxs[0])); | |
int D = stoi(KDA.substr(slashIdxs[0] + 1, slashIdxs[1] - slashIdxs[0] + 1)); | |
int A = stoi(KDA.substr(slashIdxs[1] + 1)); | |
if (K + A < D || D == 0) | |
{ | |
cout << "hasu\n"; | |
} | |
else | |
{ | |
cout << "gosu\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 20976번 2 番目に大きい整数 (0) | 2021.03.30 |
---|---|
백준 20673번 Covid-19 (0) | 2021.03.30 |
백준 20353번 Atrium (0) | 2021.03.29 |
백준 20352번 Circus (0) | 2021.03.29 |
백준 20233번 Bicycle (0) | 2021.03.29 |