본문 바로가기
  • Let's study

백준45

[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++] 백준 2776: 암기왕 문제 https://www.acmicpc.net/problem/2776 2776번: 암기왕 연종이는 엄청난 기억력을 가지고 있다. 그래서 하루 동안 본 정수들을 모두 기억 할 수 있다. 하지만 이를 믿을 수 없는 동규는 그의 기억력을 시험해 보기로 한다. 동규는 연종을 따라 다니며, www.acmicpc.net 해결방법 binary_search 함수를 통해 수첩2의 숫자가 수첩 1에 있는지 바로 확인할 수 있다. 코드 #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t, n, m, a; cin >> t; while (t--.. 2023. 4. 13.
[C++] 백준 19592: 장난감 경주 문제 https://www.acmicpc.net/problem/19592 19592번: 장난감 경주 당신을 포함한 N명의 참가자가 각자 자신의 장난감 자동차를 이용해 경주를 하는데, 트랙의 길이는 X 미터이다. 참가자는 1번부터 N번까지 번호가 매겨져 있고, 당신의 참가 번호는 N번이다. i번 www.acmicpc.net 해결방법 1. 자신을 뺀 참가자의 완주하는 데 걸리는 시간을 vector에 넣고 자신의 속도만 따로 speed 변수에 저장한다. 2. vector를 오름차순으로 정렬한다. 이 때 vector[0]은 현재 1등이다. 3. 부스터 없이 완주하는데 걸리는 시간이 vector[0]보다 작으면 단독 우승이므로 0을 출력한다. 4. 부스터를 다 사용했을 때 남은 거리를 자신의 속도로 나눈 값 (x.. 2023. 4. 12.