본문 바로가기

PKU & UVa problems

PKU 1298. The Hardest Probelm Ever 지금껏 가장 힘들었던 문제 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8523 Accepted: 4866 설명 Julius Caesar는 음모와 위험이 살아숨쉬는 시대에 살았습니다. Caesar가 겪었던 가장 힘들었던 상황은 그 스스로 살아남는 것이었습니다. 살아남기 위해서 그는 최초의 암호라고 불릴 수 있는 것을 만들었습니다. 이 암호는 믿을수 없을 정도로 완벽해서 어떻게 작동하는지 알지 않고서는 누구도 그 원리를 밝혀내지 못했습니다. 당신은 Caesar의 군대의 부사령관입니다. 당신의 임무는 Ceasar에게 온 메세지를 해독하여 사령관에게 전달하는 것입니다. 암호는 간단합니다. 평문의 각 문자를 오른쪽으로 다섯번 움직이면 안전한 메시지, .. 더보기
PKU 1298. The Hardest Problem Ever The Hardest Problem Ever Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8523 Accepted: 4866 Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one could figure it out without knowing .. 더보기
PKU 3438. Look and Say 본 뒤 말하기 Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2978 Accepted: 1905 설명 본 뒤 말하는 수열은 다음과 같습니다. 아무 숫자열 하나를 가지고 시작하는데, 그 다음으로 오는 각각의 부분열 원소는 그 전의 숫자열을 하나씩 '음성으로' 표현하는 것입니다. 예를 들면, 숫자열 122344111 은 "한 개의 1, 두 개의 2, 한 개의 3, 두 개의 4, 세 개의 1." 로 읽어지므로 그 다음에 올 수열은 1122132431입니다. 비슷하게, 숫자열 101은 1111111111 다음으로 오게 됩니다. 하지만, 어떤 숫자열을 보고 그 전의 숫자열이 유일한 표현을 가질것이라는 생각은 잘못된 것입니다. 예를 들어, 112213243.. 더보기
PKU 3438. Look and Say Look and Say Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2978 Accepted: 1905 Description The look and say sequence is defined as follows. Start with any string of digits as the first element in the sequence. Each subsequent element is defined from the previous one by "verbally" describing the previous element. For example, the string 122344111 can be described as "one 1, two 2's, .. 더보기
PKU 3030. Nasty Hacks 더러운 핵프로그램(?) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3479 Accepted: 2596 설명 당신은 Nasty Hacks 회사라는, 십대들이 그들의 멍청한 친구들을 골탕먹일때 쓸 수 있는 간단한 소프트웨어를 만드는 곳의 CEO 입니다. 이제서야 첫 상품을 개발하여 판매를 시작해야 합니다. 당신은 가능한한 많은 돈을 벌고 싶고 판매량을 늘리기 위해 광고하는 것을 생각해봅니다. 당신은 기업 분석가를 찾아가, 광고를 할 경우와 광고를 하지 않을 경우 두 경우에 대해서 각각 어떤 수익이 기대되는지를 알고자 합니다. 이제 당신은 주어진 기대 수익을 가지고, 광고를 할 것인지, 하지 않을 것인지를 결심해야 합니다. 입력 입력은 n 케이스들.. 더보기
PKU 3030. Nasty Hacks Nasty Hacks Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3479 Accepted: 2596 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends. The company has just finished their first product and it is time to sell it. You want to make as much money as possible and consider advertising in order.. 더보기
PKU 2521. How much did the businessman lose 사업가는 얼마를 잃었을까 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5019 Accepted: 3449 설명 사업가는 돈을 많이 벌 수 있습니다. 그러나 때때로 거래과정에서 돈을 많이 잃을 수도 있습니다. 예를 들어 한 사업가 Jame 은 몇몇 물품을 개당 40위안에 사서 개당 70위안에 팔 생각을 했습니다. 그리고 한 고객이 와서 물건을 사면서 Jame에게 100위안을 냈고 Jame은 30위안을 거슬러 주었습니다. 당신은 아마도, "Jame이 30위안을 벌었다"라고 할 지 모릅니다. 그러나 불행하게도 Jame은 고객에게 받은 100위안이 가짜였다는 것을 발견합니다. 참 불쌍하지요? 이 경우 Jame은 70위안을 잃었습니다.(40위안(물건의 .. 더보기
PKU 2521. How much did the businessman lose How much did the businessman lose Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5019 Accepted: 3449 Description Businessmen, of course, can make much money. However, sometimes, they would lose money in trading. For example, Jame, a businessman, brought in some goods each cost him 40 yuan and he decided to sell at the price of 70 yuan. Then a customer came to buy one, gave Jame 100 y.. 더보기
PKU 2636. Elecrical Outlets Electrical Outlets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3730 Accepted: 2806 Description Roy has just moved into a new apartment. Well, actually the apartment itself is not very new, even dating back to the days before people had electricity in their houses. Because of this, Roy's apartment has only one single wall outlet, so Roy can only power one of his electrical applianc.. 더보기
PKU 2636. Electrical Outlets 전기 콘센트 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3730 Accepted: 2806 설명 Roy는 새 아파트로 막 이사왔다. 아파트는 사실 새 것은 아니고, 집에 전기가 들어오지 않는 시대로 거슬러 올라간 것처럼 착각할 수 있는 상태이다. Roy의 아파트는 벽붙이형 콘센트가 단 하나뿐이기 때문에 Roy는 그의 가전제품을 한번에 하나씩만 전원을 공급할 수 있다. Roy는 컴퓨터로 일하면서 동시에 TV를 보는 것을 좋아하고, 청소를 하면서 HiFi system 을 큰 소리로 듣는 것을 좋아하기 때문에, 하나의 콘센트만 사용하는 것은 기능이 아니다. 사실 그는 그의 모든 가전제품을 동시에 전부 콘센트에 꽂기를 원한다. 해답은 당연히 powe.. 더보기
PKU 1979. Red and Black 빨간 것과 검은 것 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3868 Accepted: 2523 설명 정사각형의 타일이 덮어진 사각형 모양의 방이 있습니다. 각 타일은 빨간색 또는 검은색이 칠해져 있습니다. 한 남자가 검은색 타일 위에 서있습니다. 그 타일에서부터, 그는 붙어있는 4개의 타일중 하나로 움직일 수 있습니다. 단, 빨간색 타일로는 이동할 수 없으며 오로지 검은색 타일로만 이동할 수 있습니다. 위에서 설명한 방식으로 그 남자가 이동할 수 있는 검은색 타일을 세는 프로그램을 만드세요. 입력 입력할 것은 복합적인 데이터 집합들이 있습니다. 입력할 데이터 집합은 x- 축과 y- 축의 방향에 있는 타일의 갯수를 의미하는 두 개의 양정수로.. 더보기
PKU 1979. Red and Black Red and Black Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3868 Accepted: 2523 Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles. Write a program to count the number of .. 더보기
PKU 3094. Quicksum 고속합 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3382 Accepted: 2397 설명 검사합계는 데이터의 패킷을 검사하여 하나의 숫자로 되돌려 주는 알고리즘이다. 기본 구조는, 패킷이 변하면 검사합계 또한 변하고, 그러므로 검사합계는 전송상의 에러를 찾아내거나, 문서의 내용을 확인하거나, 그리고 바람직하지 않은 데이터의 변화를 찾아야 하는 수많은 경우에 필요된다. 이 문제에서는, 당신은 '고속합'이라고 불리는 검사합계 알고리즘을 충족시켜야 한다. 고속합 패킷은 대문자와 공백만을 허용한다. 그것은 언제나 시작과 끝을 대문자와 함께 한다. 반면에, 일반적인 공백과 문자는 , 연속적인 공백을 포함하여 어떤 조합도 만들 수 있다. 고속합은 각 .. 더보기
PKU 3094. Quicksum Quicksum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3382 Accepted: 2397 Description A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting transmission errors, validating document contents, and in many other situations where it is necess.. 더보기
PKU 3077. Rounders Rounders Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3128 Accepted: 2031 Description For a given number, if greater than ten, round it to the nearest ten, then (if that result is greater than 100) take the result and round it to the nearest hundred, then (if that result is greater than 1000) take that number and round it to the nearest thousand, and so on ... Input Input to this p.. 더보기
PKU 3077. Rounders 정수화하는 것들 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3128 Accepted: 2031 설명 주어진 숫자에 대해서, 10보다 크다면, 가까운 십 단위로 정수화 시키고, 또 (만약 결과가 100보다 크다면) 결과를 가까운 백 단위로 정수화 시키고, 또 (만약 결과가 1000보다 크다면) 결과를 가까운 천 단위로 정수화 시키고, 그렇게 계속... 입력 이 문제의 입력은 정수화 시킬 숫자를 지시하는 하나의 정수 n을 포함하는 행에서 시작한다. 다음 n 행들은 각각 하나의 정수 x(0 더보기
PKU 2388. Who's in the Middle 가운데 있는 것은 누구 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7089 Accepted: 4265 설명 FJ는 그의 소떼중 가장 평균적인 소를 찾으려 한다. 그는 이 '중앙값' 젖소가 우유를 얼마나 생산하는지를 알고 싶어한다: 젖소들중 절반은 우유 생산량의 중앙값보다 크거나 같게 ; 절반은 우유 생산량의 중앙값보다 작거나 같게 우유를 생산한다. 홀수인 젖소의 개체수를 N (1 더보기
PKU 2388. Who's in the Middle Who's in the Middle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7089 Accepted: 4265 Description FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much or less. Given an odd number of cows N (1 더보기
PKU 1804. Brainman. 뇌인간(?) Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3041 Accepted: 1737 설명 배경 Raymond Babbitt은 동생 Charlie 를 미치도록 몰아댔다. 최근 Raymond는 246개의 이쑤시게를 바닥에 흩뿌려놓고는 힐끗힐끗 쳐다보기만 했다. 그리고 심지어는 포커 카드를 세기까지 했다. 찰리는 같은 방식으로 머리를 쓰게 해서 엿먹이고 싶어 한다. 문제 찰리가 생각한 것은 이러하다. N개의 숫자가 늘어진 수열이 있다고 하자. 목표는 이 수열이 최종적으로 정렬되게 하는 것인데, 한번에 이웃한 두개의 숫자밖에 바꿀 수 없다. 예를 들면 : Start with: 2 8 0 3 swap (2 8) 8 2 0 3 swap (2 0).. 더보기
PKU 1804. Brainman. Brainman Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3041 Accepted: 1737 Description Background Raymond Babbitt drives his brother Charlie mad. Recently Raymond counted 246 toothpicks spilled all over the floor in an instant just by glancing at them. And he can even count Poker cards. Charlie would love to be able to do cool things like that, too. He wants to beat his brother in a.. 더보기
PKU 2649: Factovisors Factovisors Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1620 Accepted: 431 Description 팩토리얼 함수 n!은 음이 아닌 정수에 대해 다음과 같이 정의됩니다 0! = 1 n! = n * (n-1)! (n > 0) 아래의 등식을 만족하는 정수 k가 존재하면 'a는 b를 나눈다'라고 말합니다 k*a = b Input 입력은 여러 줄로 구성되며, 각 줄은 두 개의 음이 아닌(그리고 2^31 미만의) 정수 n과 m을 포함합니다 Output 각 줄의 입력에 대해, 아래에 나온 것과 같은 형태로 m이 n!을 나누는지를 판별하여 한 줄에 출력합니다 Sample Input 6 9 6 27 20 10000 20 100000 10.. 더보기
PKU 2649: Factovisors Factovisors Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1620 Accepted: 431 Description The factorial function, n! is defined thus for n a non-negative ingeger: 0! = 1 n! = n * (n-1)! (n > 0) We say that a divides b if there exists an integer k such that k*a = b Input The input to your program consists of several lines, each containing two non-negative integers, n and m, both less .. 더보기
PKU 1844. Sum. 합!? Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4816 Accepted: 3123 설명 1부터 N까지의 자연수를 생각해 봅시다. 여기에 부호를 붙여보도록 하지요.(+나 -). 그리고 그대로 더해버려서 합계 S를 만들어 봅시다. 문제는 S를 이루기 위한 이 자연수들의 최소 갯수를 구하는 것입니다. 1부터 N까지 모두 쓰되 부호는 마음대로 붙여서 S를 만들기 위해 가장 적은 개수의 숫자로 S를 구성할 수 있게 합시다. 주어진 합 S에 대하여, 1부터 N까지 부호는 마음대로 붙여 최소의 N이 되는 경우를 구해 N을 출력하세요. 입력 한 줄만 입력받되, 합인 S를 0보다는 크고 100000보다는 작은(0< S 더보기
PKU 1844. Sum. Sum Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4816 Accepted: 3123 Description Consider the natural numbers from 1 to N. By associating to each number a sign (+ or -) and calculating the value of this expression we obtain a sum S. The problem is to determine for a given sum S the minimum number N for which we can obtain S by associating signs for all numbers between 1 to N. For a.. 더보기
PKU [3685]. Matrix. Matrix Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 2290 Accepted: 415 Description N by N 행렬 A가 주어진다. 그 중 이 행렬의 i행 j열 성분인 Ai j 는 다음과 같은 방정식을 만족한다. : i 2 + 100000 × i + j 2 - 100000 × j + i × j. 당신은 이 행렬에서 M번째로 작은 값을 찾아야 한다. Input 첫번째 행의 입력은 테스트 케이스의 수이다. 각 테스트 케이스는 두 정수 N(1 ≤ N ≤ 50,000) 과 M(1 ≤ M ≤ N × N) 으로 구성되며, N과 M의 입력 이전엔 공백이 존재한다. Output 각 테스트 케이스 별로 답을 찾아내서 한 줄에 출력하라. Sampl.. 더보기
PKU [3685]. Matrix. Matrix Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 2290 Accepted: 415 Description Given a N × N matrix A, whose element in the i - th row and j - th column Ai j is an number that equals i 2 + 100000 × i + j 2 - 100000 × j + i × j, you are to find the M - th smallest element in the matrix. Input The first line of input is the number of test case. For each test case there is only on.. 더보기
PKU 2017, Speed Limit. 속도제한? Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6123 Accepted: 4485 설명 Bill과 Ted는 길을 따라 여행하려 합니다. 하지만 차가 고장나버려서, 얼마나 달려왔는지 잘 알 수 없습니다. 운이 좋다고 해야 하나? Bill은 제대로 작동하는 스톱워치를 가지고 있었고, 그들이 달린 총 시간과 속도를 기록 할 수 있었지요. 그런데 또 어쩌나? 기록을 웃기게 해버려서... 시간단위로 끊지를 못했네요. 실제 달린 거리를 쉽게 측정하도록 계산해주는 프로그램을 만들어주세요~ 예를 들면, 아래 표와 같아요. 시간당 달린 마일(속도) 경과한 총 시간 20 2 30 6 10 7 위 표 대로라면... 2시간동안 시간당 20마일의 속도로 달렸.. 더보기
PKU 2017, Speed Limit. Speed Limit Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6123 Accepted: 4485 Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can record their speed and the total time they have driven. Unfortunately, their record keeping strategy is a litt.. 더보기
PKU [2027]. No Brainer. No Brainer Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7468 Accepted: 5631 Description Zombies love to eat brains. Yum. Input The first line contains a single integer n indicating the number of data sets. The following n lines each represent a data set. Each data set will be formatted according to the following description: A single data set consists of a line "X Y", where X is th.. 더보기
PKU [2027]. No Brainer. No Brainer Time Limit: 1000MS Memory Limit: 30000K Description 좀비는 뇌를 먹는것을 좋아한다. Yum.( -_-; ) Input 첫 번째 행의 입력은 데이터 셋의 갯수를 의미하는 단 하나의 정수 n 이다. 이후 n개의 행에는 각각 데이터 셋이 들어간다. 각각의 데이터 셋은 다음과 같은 정의에 따라 입력된다 : 한 데이터 셋은 한 행에 "X Y" 로 구성된다. X는 좀비가 먹은 뇌의 갯수이며, Y는 좀비가 살아가기 위해 먹어야 하는 뇌의 갯수이다. Output 각 데이터 셋트별로 한 행의 출력이 있어야 한다. 만약 좀비가 먹은 뇌의 갯수가 좀비가 살아가기 위해 먹어야 하는 뇌의 갯수보다 같거나 많다면 "MMM BRAINS" 를 출력하고, 그 이외의 경우에는.. 더보기