본문 바로가기

PKU & UVa problems

PKU 2234. Matches Game 성냥 놀이 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2658 Accepted: 1536 설명 간단한 게임이 있습니다. 이 게임은 두 명의 플레이어와 여러 개의 쌓여진 성냥개비가 있습니다. 두 명의 플레이어는 턴을 나누어서 진행합니다. 각 턴을 진행하는 플레이어는 쌓여진 성냥개비에서 임의의 성냥개비를 덜어냅니다(물론 덜어낼 성냥개비는 0개이어서는 안되고, 덜어낼 성냥개비는 한 뭉치 안에서만 덜어내야 합니다). 한 플레이어의 턴이 끝나고 나서 성냥이 하나도 남지 않으면, 그 플레이어의 승리가 됩니다. 두 명의 플레이어 모두는 매우 똑똑하다는 가정을 해봅시다. 당신이 할 일은 먼저 플레이 하는 사람이 게임에서 이길지 질지 를 알아내는 것입니다. .. 더보기
PKU 2234. Matches Game Matches Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2658 Accepted: 1536 Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of matches, which is taken away, cannot be zero and cannot be .. 더보기
PKU 2243. Knight Moves 나이트의 움직임 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3541 Accepted: 2177 설명 당신의 친구가 TKP 를 조사하고 있고, 당신은 막혀진 공간에서의 나이트의 움직임을 조사해야 하는데 그 조사할 움직임은 주어진 n개의 정사각형 칸들을 한번에 움직이는 방법입니다. 그가 생각하기로, 문제의 가장 어려운 부분은 두 개의 주어진 정사각형의 칸을 나이트가 최소한으로 움직이는 숫자를 결정하는 것이고, 이것은 당신이 예전에 해냈던 것이므로, 찾아내는 것은 쉬울 것입니다. 물론 당신은 그것이 문제를 푸는 그 자체라는 것 또한 알고 있습니다. 그래서 당신은 그 친구에게 "어려운" 부분을 풀 프로그램을 짜도록 제안합니다. 당신이 해야 할 일은 .. 더보기
PKU 2243. Knight Moves Knight Moves Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3541 Accepted: 2177 Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determining the smal.. 더보기
PKU 2840. Big Clock 대형 시계 Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4397 Accepted: 2802 설명 목사님이 교회의 시계를 수리하기 위해 몇 주간 돈을 모으셨습니다. 그 시계는 매 시간마다 소리를 냈었는데, 몇 주 전에 고장이 난 뒤로 조용했습니다. 시계가 고쳐진 뒤로는, 잘 작동했지만 여전히 문제가 좀 있었습니다. 시계가 1시에는 13번, 2시에는 14번... 12시에는 24번, 13시에는 1번 소리를 냈습니다. 지금은 몇번이나 소리를 낼까요? 입력 첫 번째 줄은 단 하나의 정수 T (T 더보기
PKU 2840. Big Clock Big Clock Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4397 Accepted: 2802 Description Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days and nights, was damaged several weeks ago and had been silent since then. After the clock was repaired, it works all right, but there is still something wrong with it: t.. 더보기
PKU 2656. Unhappy Jinjin Unhappy Jinjin Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5645 Accepted: 4199 Description Jinjin is a junior school student. Besides the classes in school, Jinjin's mother also arranges some supplementary classes for her. However, if Jinjin studies for more than eight hours a day, she will be unhappy on that day. On any day she gets unhappy, the more time she studies, the unhappi.. 더보기
PKU 2656. Unhappy Jinjin 우울한 Jinjin Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5645 Accepted: 4199 설명 Jinjin은 초등학생입니다. 학교 수업이 있는데도, Jinjin의 어머니는 그녀가 해야 할 보충수업을 잡았습니다. 그러나 Jinjin은 하루에 8시간을 초과하여 공부하면 그날 우울해집니다. 우울한 날이 되면, 그녀는 공부를 더 하고, 따라서 우울한 정도가 더 심해집니다. 이제 우리는 앞으로 며칠동안 Jinjin의 공부시간을 정해야 하는데, 따라서 당신이 해야 할 일은 그녀가 그 며칠동안 우울해지는지 그렇지 않은지 이고, 만약 우울해진다면 어떤 날이 제일 우울해지는 날일지를 알아내는 것입니다. 입력 여러 테스트 케이스가 있을 것입니다. 각 .. 더보기
PKU 1163. The Triangle The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13569 Accepted: 7789 Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1)Figure 1은 숫자로 이루어진 삼각형입니다. 맨 위에서 시작해서 맨 아래의 한 지점에서 끝나는 임의의 길을 지나는 숫자들의 합들 중 가장 큰 것을 계산하는 프로그램을 만드세요. 각 스텝에서는 왼쪽아래 또는 오른쪽아래로 갈 수 있습니다. Input 당신의 프로그램은 표준 입력으로 읽어들입니다. 첫째 줄은 하나의 정수 N을 포함하는데, 이것은 삼각형의 행의 개수를 의미합니다. 그 뒤의 N개 줄은 삼각형의 데이터를 서술합니다. 삼각형의 행의 개수는 1.. 더보기
PKU 1163. The Triangle The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13569 Accepted: 7789 Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. In.. 더보기
PKU 2039. To and Fro To and Fro Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4308 Accepted: 2832 Description Mo와 Larry는 메세지를 암호화하는 한 방법을 고안해냈습니다. 그들은 먼저 은밀히 열의 수를 정하고 그 열을 따라 아래로 메세지를 (글자만) 써내려간 후, 글자들의 배열을 직사각형으로 만들기 위해 임의의 글자를 패드로 붙입니다. 예를 들어, 메세지가 "There’s no place like home on a snowy night" 이고 5개의 열이 있다면, Mo는 아래와 같이 쓸 것입니다. t o i o y h p k n n e l e a i r a h s g e c o n h s e m o t n l e w x 하나 주.. 더보기
PKU 2039. To and Fro To and Fro Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4308 Accepted: 2832 Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is "There’s no place like.. 더보기
UVa 324. Factorial Frequencies 324 - Factorial FrequenciesTime limit: 3.000 seconds Factorial Frequencies 불 보듯 뻔히 보이는 사업의 하락세를 보강하기 위하여, Madam Pheonix는 그녀의 고객들에게 여러 종류의, 수를 이용한 점 서비스를 하기로 했습니다. 그녀는 십진수로 표현되는 팩토리얼의 각 자리에 있는 숫자들의 개수의 합이, 그들이 겪게 될 미래의 일들의 가짓수를 표현할 수 있다고 믿도록 만들었습니다.그러나 단순한 손금보기와는 다르게, 그녀는 이 수열들을 단숨에 계산하여 알려줄 능력이 되지 못했기에 당신을 고용하여 각 값들을 결정하려 합니다. n!(n 팩토리얼)의 정의가 1*2*3*...*n임을 잊지 마세요. 그녀가 한 주의 , 한 달의, 혹은 한 해 중의 하루의 .. 더보기
UVa 324. Factorial Frequencies 324 - Factorial FrequenciesTime limit: 3.000 seconds Factorial Frequencies In an attempt to bolster her sagging palm-reading business, Madam Phoenix has decided to offer several numerological treats to her customers. She has been able to convince them that the frequency of occurrence of the digits in the decimal representation of factorials bear witness to their futures. Unlike palm-reading, how.. 더보기
PKU 1455. Crazy Tea Party 미친 차 파티 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4055 Accepted: 2736 설명 미친 차 파티>>에 참가한 n명의 참가자들이 테이블에 둘러앉아있습니다. 매 분마다 한 쌍의 이웃한 사람들이 서로 자리를 바꿀 수 있습니다. 모든 참가자가 역순으로 앉을때까지 걸리는 시간을 구하세요. 입력 첫 번째 줄은 테스트할 시행횟수입니다. 다음 각 줄은 하나의 양정수 n (1 더보기
PKU 1455. Crazy Tea Party Crazy tea party Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4055 Accepted: 2736 Description n participants of > sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to sit in reverse order (so that left neighbors would become right, and right - left). Input The first line is the amount of .. 더보기
PKU 2719. Faulty Odometer 고장난 주행거리계 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5004 Accepted: 3159 설명 당신은 차의 주행거리를 정수로 표시해주는 주행거리계가 달린 차를 보고 있습니다. 그러나 그 주행거리계는 좀 고장이 나서, 언제나 숫자 4를 뛰어넘고 3에서 5로 바꿔버립니다. 이 고장은 일의 자리 뿐만이 아닌, 각 자리에서 문제를 일으킵니다. 예를 들면 주행거리계가 15339 마일이 표시된 상태에서 1마일을 더 움직이면 주행거리계는 15340 마일이 나오는 대신 15350 마일을 보여줍니다. 입력 각 줄은 1..999999999의 범위 안에 있는, 주행거리계에 표시된 숫자로, 앞자리의 0은 생략한 상태의 양정수로 입력합니다. 입력을 종료할 때.. 더보기
PKU 2719. Faulty Odometer Faulty Odometer Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5004 Accepted: 3159 Description You are given a car odometer which displays the miles traveled as an integer. The odometer has a defect, however: it proceeds from the digit 3 to the digit 5, always skipping over the digit 4. This defect shows up in all positions (the one's, the ten's, the hundred's, etc.). For example, if.. 더보기
UVa 200. Rare Order Rare Order 한 희귀 서적 수집가가 최근에 어떤 책이 영어와 같은 문자로 이루어져 있지만 낯설은 언어로 적혀있는 것을 발견하였습니다. 짧은 색인이 있지만, 영어의 알파벳과 같이 생각하지 못할만큼 다른 순서로 적혀있었습니다. 수집가는 색인을 이용하여 문자의 순서를 확인해보려 했지만 지루함과 당혹감을 느끼며 포기했습니다. 당신은 수집가의 작업을 마무리할 프로그램을 작성해야 합니다. 특히, 이미 특정 방법에 의해 짜여진 문자열들을 분류하고 어떤 순서인지를 알아내야 합니다. 입력 입력은 대문자로, 한 줄에 한 문자열이 들어갑니다. 각 문자열은 최대 20개의 문자를 포함할 수 있습니다. 목록의 마지막은 '#' 문자를 사용합니다. 모든 문자가 사용되어야 하는건 아니지만, 목록에 사용된 문자들 모두가 특정 방.. 더보기
UVa 200. Rare Order Rare Order A rare book collector recently discovered a book written in an unfamiliar language that used the same characters as the English language. The book contained a short index, but the ordering of the items in the index was different from what one would expect if the characters were ordered the same way as in the English alphabet. The collector tried to use the index to determine the order.. 더보기
PKU 2551. Ones 1들 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5098 Accepted: 2912 설명 2와 5로 나누어지지 않는 정수 n의 범위가 0 더보기
PKU 2551. Ones Ones Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5098 Accepted: 2912 Description Given any integer 0 더보기
PKU 1904. King's Quest 왕의 부탁 Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 1493 Accepted: 494 Case Time Limit: 2000MS 설명 옛날 옛적에 N 명의 아들들이 있는 왕이 있었습니다. 또한 왕궁에는 N명의 아름다운 소녀들이 있었고 N 명의 아들들이 그 소녀들을 좋아한다는 것을 왕이 알아챘습니다. 그러나 왕의 아들들은 젊고 무뇌였기에 한 아들이 여러 명의 소녀를 좋아하는 경우도 있었습니다. 그래서 왕은 마법사에게, 그의 아들들이 각자가 원하는 소녀와 결혼할 수 있도록 하라고 시켰습니다. 그리고 마법사는 그 일을 해내어서 각 왕자가, 결혼하기를 원하는 소녀를 골랐는데, 당연하게도 일부일처제의 방식이었습니다. 그러나 왕은 그 결과를 보고 말.. 더보기
PKU 1904. King's Quest King's Quest Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 1493 Accepted: 494 Case Time Limit: 2000MS Description Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king knew about each of his sons which of those girls he did like. The sons of the king were young and light-headed, so it was possible for one son to like sev.. 더보기
PKU 1953. World Cup Noise 월드컵 소음 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5818 Accepted: 2851 설명 배경지식 "KO-RE-A, KO-RE-A" 54000명의 행복에 가득찬 축구 팬들이, 한국 팀이 조국에서 열린 FIFA 월드컵 준결승에 올랐을때 소리쳤다. 그러나 비록 그들의 그런 흥분감이 정말이었더라도, 한국 사람들은 여전히 조직적이었다. 예를 들면 그들은 배의 고동소리와 비슷하게 들릴 정도의, 큰 트럼펫들을 준비하여 경기장에서 뛰는 한국팀을 응원했다. 팬들은 경기가 진행되는 내내 소음의 수준을 유지하려 했다. 트럼펫은 압축가스로 작동되었다. 그러나 만약 트럼펫을 2초 이상 쉬지 않고 분다면 그것은 고장날 것이다. 그래서 트럼펫으로 소리를 낼 때.. 더보기
PKU 1953. World Cup Noise World Cup Noise Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5818 Accepted: 2851 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in their home country. But although their excitement is real, the Korean people are still very organized by nature. For example, they have organized huge trumpets.. 더보기
PKU 2845. 01000001 01000001 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5031 Accepted: 1654 설명 이진수를 더하는 것은 매우 쉬운 일이며, 일반적인 십진수의 덧셈과 매우 유사합니다. 십진수를 더할때와 같이, 당신은 한 번에 한 줄에 있는 비트(아라비아 숫자)들을 오른쪽에서 왼쪽으로 씁니다. 십진수끼리의 덧셈과는 달리, 이진수들을 더할때에 기억해야 할 것이 몇가지 있습니다 : 0 + 0 = 0 1 + 0 = 1 0 + 1 = 1 1 + 1 = 10 1 + 1 + 1 = 11 십진수의 덧셈과 같이, 한 줄에 더해진 총합이 두 자리 비트(두 자리 수)일 경우 의미가 적은 숫자는 총 합의 부분으로 쓰여지고 의미가 큰 숫자는 왼쪽 줄로 '옮겨집니다'.. 더보기
PKU 2845. 01000001 01000001 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5031 Accepted: 1654 Description Adding binary numbers is a very simple task, and very similar to the longhand addition of decimal numbers. As with decimal numbers, you start by adding the bits (digits) one column at a time, from right to left. Unlike decimal addition, there is little to memorize in the way of rules for the addit.. 더보기
PKU 1089. Intervals 구간 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2973 Accepted: 1158 설명 n개의 폐구간 [ai; b i], i=1,2,...,n 이 주어졌습니다. 이 구간들의 합은 교차하지 않는 폐구간들의 쌍으로 표현될 수 있습니다. 당신이 해야 할 일은 이러한 구간들의 표현을 최소한의 숫자로 하는 것입니다. 이렇게 표현할 구간들은 오름차순으로 출력되어야 합니다. 오름차순이란 a 더보기
PKU 1089. Intervals Intervals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2973 Accepted: 1158 Description There is given the series of n closed intervals [ai; b i], where i=1,2,...,n. The sum of those intervals may berepresented as a sum of closed pairwise non−intersecting intervals. The task is to find such representation with the minimal number of intervals. The intervals of this representation sho.. 더보기