본문 바로가기

전체 글740

[백준 13939] Imena [Java] 문제Little Mirko likes to type and often gets bored during class, which is why his teacher assigned him a task.Mirko must retype a book​ that contains N space-separated sentences. In this book, a sentence​ is an array of one or more space-separated words, where only the last word’s character is a punctuation mark ( '.', '?' or '!' ). The rest of the words do not contain punctuation marks.Words are.. 2024. 7. 18.
[백준 02579] 계단 오르기 [C/C++] 문제계단 오르기 게임은 계단 아래 시작점부터 계단 꼭대기에 위치한 도착점까지 가는 게임이다. 과 같이 각각의 계단에는 일정한 점수가 쓰여 있는데 계단을 밟으면 그 계단에 쓰여 있는 점수를 얻게 된다.예를 들어 와 같이 시작점에서부터 첫 번째, 두 번째, 네 번째, 여섯 번째 계단을 밟아 도착점에 도달하면 총 점수는 10 + 20 + 25 + 20 = 75점이 된다.계단 오르는 데는 다음과 같은 규칙이 있다.계단은 한 번에 한 계단씩 또는 두 계단씩 오를 수 있다. 즉, 한 계단을 밟으면서 이어서 다음 계단이나, 다음 다음 계단으로 오를 수 있다.연속된 세 개의 계단을 모두 밟아서는 안 된다. 단, 시작점은 계단에 포함되지 않는다.마지막 도착 계단은 반드시 밟아야 한다.따라서 첫 번째 계단을 밟고 이어 두.. 2024. 7. 18.
[백준 06190] Another Cow Number Game [Python] 문제The cows are playing a silly number game again. Bessie is tired of losing and wants you to help her cheat. In this game, a cow supplies a number N (1 If N is odd, then the number N is multiplied by 3 and incremented by 1. If N is even, the number N is divided by 2. Each time the number is multiplied or divided, the score increases by one point. The game ends -- and the score is finalized -- wh.. 2024. 7. 18.
[백준 09095] 1, 2, 3 더하기 [C/C++] 문제정수 4를 1, 2, 3의 합으로 나타내는 방법은 총 7가지가 있다. 합을 나타낼 때는 수를 1개 이상 사용해야 한다.1+1+1+11+1+21+2+12+1+12+21+33+1정수 n이 주어졌을 때, n을 1, 2, 3의 합으로 나타내는 방법의 수를 구하는 프로그램을 작성하시오.입력첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 n이 주어진다. n은 양수이며 11보다 작다.출력각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다.풀이T번 동안 1, 2, 3으로 정수 n을 만들기 위한 모든 경우의 수를 구하는 문제다.dp[i] : i를 만들 수 있는 경우의 수n을 구성하기 위해 문제에서 주어진 연산은 1, 2, 3을 합해서 만.. 2024. 7. 17.
[백준 06162] Superlatives [Python] 문제Typically, droughts are classified into “abnormally dry”, “moderate drought”, “severe drought”, “extreme drought”, and “exceptional drought”. The current drought is so “exceptional” in most of California that there have been discussions of adding one or more steps to the scale. But really, that will only delay the problem. Any system of discrete labels is not completely scalable. As computer s.. 2024. 7. 17.
[백준 01463] 1로 만들기 [C/C++] 문제 https://www.acmicpc.net/problem/1463풀이N을 1로 만들기 위한 연산을 최소화하는 문제다.dp[i] : i를 만들기 위한 최소 연산 횟수기본적으로 dp[i]는 dp[i - 1]에 1을 더해 만들 수 있다, dp[i] = dp[i - 1] + 1i가 만약 2 또는 3의 배수라면, 1, 2번 연산에 의해 곱셈으로 계산하는게 이득이다.단, 2보다는 3으로 곱셈하는 것이 연산 횟수가 더 최소화되므로 dp 갱신 순서에 유의하자.소스코드보기 2024. 7. 15.