본문 바로가기
  • Let's study

PS56

[C++] 백준 3765: Celebrity jeopardy 문제 https://www.acmicpc.net/problem/3765 3765번: Celebrity jeopardy It’s hard to construct a problem that’s so easy that everyone will get it, yet still difficult enough to be worthy of some respect. Usually, we err on one side or the other. How simple can a problem really be? Here, as in Celebrity Jepoardy, questions www.acmicpc.net 해결방법 getline으로 입력값이 없을 때까지 입력받고 그대로 출력하면 된다. 코드 #include #includ.. 2023. 5. 7.
[C++] 백준 21638: SMS from MCHS 문제 https://www.acmicpc.net/problem/21638 21638번: SMS from MCHS The first line of input contains two integers $t_1$ and $v_1$ --- the temperature and the wind speed for today ($-50 \le t_1 \le 50$; $0 \le v_1 \le 20$). The second line contains two integers $t_2$ and $v_2$ --- the temperature and the wind speed for tomo www.acmicpc.net 해결방법 오늘과 내일의 온도와 풍속을 비교하여 적절한 조건마다 올바른 문장을 출력해주면 된다. 코드 #inclu.. 2023. 5. 6.
[C++] 백준 24072: 帰省 (Homecoming) 문제 https://www.acmicpc.net/problem/24072 24072번: 帰省 (Homecoming) ビーバーのビ太郎は帰省することにした.今日から A 日後の午前に実家に着き,今日から B 日後の午前に実家を去る.それを聞きつけたビーバーのビバ子は,今日から C 日後の午後にビ www.acmicpc.net 해결방법 비타로는 a일 후의 오전에 도착해 b일 후의 오전에 떠나므로 c일 후에 도착하는 비바코는 a일 ~ b-1일 사이에 도착해야 비타로와 만날 수 있다. 코드 #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a, b, c; cin >> a >> b >> c; if (c.. 2023. 5. 5.
[C++] 백준 21354: Äpplen och päron 문제 https://www.acmicpc.net/problem/21354 21354번: Äpplen och päron En rad med två heltal $A,P$ ($0 \le A,P \le 1000)$, antalet äpplen Axel har lyckats sälja, och antalet päron Petra har lyckats sälja. www.acmicpc.net 해결방법 1. 사과의 가격 7 * 사과의 개수와 배의 가격 13 * 배의 개수를 비교한다. 2. 총 판매 가격이 배가 더 크면 "Petra", 사과가 더 크면 "Axel", 동일하면 "lika"를 출력한다. 코드 #include using namespace std; int main() { ios_base::sync_with_.. 2023. 5. 4.
[C++] 백준 11656: 접미사 배열 문제 https://www.acmicpc.net/problem/11656 11656번: 접미사 배열 첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000보다 작거나 같다. www.acmicpc.net 해결방법 1. 입력 받은 문자열을 substr 함수를 이용하여 각각의 접미사를 따로 배열에 저장한다. substr은 (시작지점, 길이)를 전달받아 부분 문자열을 리턴하므로 시작지점을 0~문자열 길이-1까지 넣어주면 된다. 2. sort를 사용하여 정렬 후 출력한다. 코드 #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0.. 2023. 4. 27.
[C++] 백 11721: 열 개씩 끊어 출력하기 문제 https://www.acmicpc.net/problem/11721 11721번: 열 개씩 끊어 출력하기 첫째 줄에 단어가 주어진다. 단어는 알파벳 소문자와 대문자로만 이루어져 있으며, 길이는 100을 넘지 않는다. 길이가 0인 단어는 주어지지 않는다. www.acmicpc.net 해결방법 string을 하나씩 출력해주되 10번째 문자일 때(i%10==0일 때) 줄바꿈을 출력해준다. 이 때 i=0부터 시작하므로 i != 0 조건을 안 넣으면 i=0일 때도 줄바꿈을 출력하니 주의하자! 코드 #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string str; .. 2023. 4. 26.