Search results

'Computer Science'에 해당하는 글들

  1. 2009/04/25  [PKU] P3062: Celebrity jeopardy
  2. 2009/04/23  [PKU] P1298: The Hardest Problem Ever (2)
  3. 2009/04/01  Computer Music Project - Alpha+
  4. 2009/03/31  Computer Music Project - alpha
  5. 2009/03/15  [PKU] P1316: Self Numbers
  6. 2009/03/15  [PKU] P1306: Combinations
  7. 2009/03/15  [PKU] P1004: Financial Management
  8. 2009/03/15  [PKU] P1003: Hangover
  9. 2009/03/15  [PKU] P1002: 487-3279

Description

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 and answers are a bit confused, and, because the participants are elebrities, there’s a real need to make the challenges simple. Your program needs to prepare a question to be solved --- an equation to be solved --- given the answer. Specifically, you have to write a program which finds the simplest possible equation to be solved given the answer, considering all possible equations using the standard mathematical symbols in the usual manner. In this context, simplest can be defined unambiguously several different ways leading to the same path of resolution. For now, find the equation whose transformation into the desired answer requires the least effort.

For example, given the answer X = 2, you might create the equation 9 - X = 7. Alternately, you could build the system X > 0; X^2 = 4. These may not be the simplest possible equations. Solving these mind-scratchers might be hard for a celebrity.

Input

Each input line contains a solution in the form <symbol> = <value>

Output

For each input line, print the simplest system of equations which would to lead to the provided solution, respecting the use of space exactly as in the input.

Sample Input

Y = 3
X=9

Sample Output

Y = 3
X=9

Solution:

more..


2009/04/25 15:38 2009/04/25 15:38

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 how it worked.

You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e., if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite:


Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.

Input

Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. All characters will be uppercase.


A single data set has 3 components:

  1. Start line - A single line, "START"
  2. Cipher message - A single line containing from one to two hundred characters, inclusive, comprising a single message from Caesar
  3. End line - A single line, "END"

Following the final data set will be a single line, "ENDOFINPUT".

Output

For each data set, there will be exactly one line of output. This is the original message by Caesar.

Sample Input

START
NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX
END
START
N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ
END
START
IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ
END
ENDOFINPUT

Sample Output

IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES
I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME
DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE

Source




Solution:

more..


2009/04/23 18:59 2009/04/23 18:59
음..
수업도 다 째고 방에 쳐박혀서 코딩만 했더니, 어느정도 진전이 있었네요..

알고리즘이라든가, 딱히 고난이도 프로그래밍이 필요한 것은 아니지만,
아무래도 GUI쪽은 처음 다뤄보는 부분이라 시간이 엄청 오래 걸리는군요..

어제 새벽에는 친구가 아주 간지나게 코딩해놓은 인프라 스트럭쳐와 연결하는 작업을 했습니다.
(생각보다 이것저것 신경써야할게 많았습니다.)

연동작업을 하면서, 동시에 GUI부분에서 필요한 것들을 몇 개 추가하였고
제가 체력의 한계를 느껴서 기절한 동안 친구가 또 한 건을 해놓고 학교를 갔네요 -_-a
(크크, 대단한 친구놈입니다 -_-)


다음은 이번 Interim Report 용으로 제출한 프로그램 스크린샷입니다:


사용자 삽입 이미지





















▲이게 저희가 작업하는 확장기능을 추가할 메인 프레임입니다.


사용자 삽입 이미지

















▲ 저희가 만든 GUI frame. 메인프레임에 장착(?) 한 모습 -_-a


사용자 삽입 이미지

















▲ 줌인 기능을 사용했을 경우, 칸 간격이 늘어납니다.


사용자 삽입 이미지

















▲ 물론, 줌아웃 기능을 사용하면, 칸 간격이 촘촘해지죠.



사용자 삽입 이미지

















▲ 마우스로 드래그&드랍으로 그려본 노트 입니다. (C7으로 2.5초에서 8.6초 까지, AS6으로 6.2초 부터14초)



사용자 삽입 이미지

















▲ 위에 있는 configuration 메뉴를 이용해서 노트를 생성하는 예제입니다. (C6로 4초부터 8.23초 동안 연주)



사용자 삽입 이미지

















▲ Name 파라미터는 각 sound의 name을 뜻하는데, 각 이름마다 unique한 색깔을 가지고 있습니다.
    (또한, duration으로의 생성이 아닌 end time으로도 생성이 가능한걸 보여주는 예제입니다.)



사용자 삽입 이미지

















▲ 색깔 변화의 또다른 예제.



사용자 삽입 이미지

















▲ 노트들이 그려져있는 상태에서 줌인 기능 사용. (세밀한 수정작업이 가능해집니다)


사용자 삽입 이미지

















▲ 노트들이 그려져있는 상태에서 줌아웃 기능 사용. (전체적인 구조를 볼 수 있습니다)



앞으로 추가해야할 기능들이 산더미같이 쌓여있지만,
해결못했던 부분들이 해결되어서 기분이 좋네요.

이제부턴 거의 학기 말까지 이 프로젝트에 전념을 해서 5월 1일 전까지 완성을 해야합니다 ^^a

그동안 이것저것 할 것도 많고 바쁘겠지만, 틈틈히 해서 유종의 미를 거둬야겠네요.




2009/04/01 12:14 2009/04/01 12:14
음.. 학교 과목 프로젝트중 하나 인지라.. School 로 분류해야할지,
java 프로그래밍이라 java에 넣어야할지 고민하다가,
그냥 java에 넣기로.. 결심했습니다.


Computer Music [15-322] Final Project - alpha

일단 4월 1일, 즉 이번주 수요일 저녁까지 프로젝트의 interim report를 내야하는데요..

이 프로젝트의 첫번째 파트였던 Proposal은 다행히 만점이 나와서 기분 좋....게...작업하고있습니다...
(그렇고 말고요..)

일단 proposal에서 약속했던 바와 같이, interim report까지 프로젝트의 GUI 부분을 완성하겠다고 했는데..

막상 이런 저런 일들이 겹치는 바람에, 그저께 밤에서야 들여다보기 시작햇네요..

일단 프로젝트 성격상, 새로운 프로그램을 만드는게 아니라 기존의 것 (교수가 만든 프로그램)의 기능을
확장하는것이기 때문에..
많은 시간을 이미 존재하는 코드를 읽는데 소비했습니다.
약 5시간 반 정도 전부터 코딩 작업을 한결과,
대충 구조는 잡았고, 내부 구조 및 data structure 도 프로젝트 파트너인 제 친구가 많은 부분 완성했습니다.
(물론, 기본적인 structure만 구성해놓은 상태라... 갈길은 멉니다만..)

사용자 삽입 이미지

네..그냥 보시면 뭔지 잘 모르실거고.. 그게 자연스러운겁니다 -_-
아래 두개의 네모칸에 제일 핵심적인 요소가 들어가기 때문에...
원하는대로 구현을 해보려고 갖가지 노력을 해봤으나.. 결국 삽질로 돌아가는 바람에..
이렇게 잠시 쉬고자 포스팅이나 하고 있네요..

현재로써는 Save기능과 Load기능을 완성해놓은 상태이고, 친구가 해놓은 부분과 연동만 하면
Add 부분도 곧바로 사용 가능해지도록 해놓았습니다.

아직은 거의 껍데기에 불과하지만.. 몇 주이내로 꽤 쓸만한 (이 수업에서만 -_-) 툴이 되리라 믿습니다..

[오픈소스 프로젝트이므로, 완성된 후에 이 프로젝트에 대한 마지막 포스팅글에 코드를 동봉하겠습니다]




2009/03/31 06:41 2009/03/31 06:41

Description

In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for digitadition, a term coined by Kaprekar.) For example, d(75) = 75 + 7 + 5 = 87. Given any positive integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), .... For example, if you start with 33, the next number is 33 + 3 + 3 = 39, the next is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence

33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...
The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with no generators is a self-number. There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.

Input

No input for this problem.

Output

Write a program to output all positive self-numbers less than 10000 in increasing order, one per line.

Sample Input

Sample Output

1
3
5
7
9
20
31
42
53
64
|
| <-- a lot more numbers
|
9903
9914
9925
9927
9938
9949
9960
9971
9982
9993

Source


Solution:

more..


2009/03/15 22:07 2009/03/15 22:07

Description

Computing the exact number of ways that N things can be taken M at a time can be a great challenge when N and/or M become very large. Challenges are the stuff of contests. Therefore, you are to make just such a computation given the following:
GIVEN: 5 <= N <= 100; 5 <= M <= 100; M <= N
Compute the EXACT value of: C = N! / (N-M)!M!
You may assume that the final value of C will fit in a 32-bit Pascal LongInt or a C long. For the record, the exact value of 100! is:
93,326,215,443,944,152,681,699,238,856,266,700,490,715,968,264,381,621, 468,592,963,895,217,599,993,229,915,608,941,463,976,156,518,286,253, 697,920,827,223,758,251,185,210,916,864,000,000,000,000,000,000,000,000

Input

The input to this program will be one or more lines each containing zero or more leading spaces, a value for N, one or more spaces, and a value for M. The last line of the input file will contain a dummy N, M pair with both values equal to zero. Your program should terminate when this line is read.

Output

The output from this program should be in the form:
N things taken M at a time is C exactly.

Sample Input

100  6
20 5
18 6
0 0

Sample Output

100 things taken 6 at a time is 1192052400 exactly.
20 things taken 5 at a time is 15504 exactly.
18 things taken 6 at a time is 18564 exactly.

Source


Solution:


more..


2009/03/15 21:58 2009/03/15 21:58

Description

Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what's been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

Input

The input will be twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.

Output

The output will be a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. There will be no other spaces or characters in the output.

Sample Input

100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

Sample Output

$1581.42

Source


Solution:


more..


2009/03/15 19:30 2009/03/15 19:30

Description

How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicular to the table.) With two cards you can make the top card overhang the bottom one by half a card length, and the bottom one overhang the table by a third of a card length, for a total maximum overhang of 1/2 + 1/3 = 5/6 card lengths. In general you can make n cards overhang by 1/2 + 1/3 + 1/4 + ... + 1/(n + 1) card lengths, where the top card overhangs the second by 1/2, the second overhangs tha third by 1/3, the third overhangs the fourth by 1/4, etc., and the bottom card overhangs the table by 1/(n + 1). This is illustrated in the figure below.


사용자 삽입 이미지

Input

The input consists of one or more test cases, followed by a line containing the number 0.00 that signals the end of the input. Each test case is a single line containing a positive floating-point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three digits.

Output

For each test case, output the minimum number of cards necessary to achieve an overhang of at least c card lengths. Use the exact output format shown in the examples.

Sample Input

1.00
3.71
0.04
5.19
0.00

Sample Output

3 card(s)
61 card(s)
1 card(s)
273 card(s)

Source



Solution:


more..


2009/03/15 19:19 2009/03/15 19:19

Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2
D, E, and F map to 3
G, H, and I map to 4
J, K, and L map to 5
M, N, and O map to 6
P, R, and S map to 7
T, U, and V map to 8
W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters.

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:

No duplicates.

Sample Input

12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3

Source




Solution:


more..


2009/03/15 18:23 2009/03/15 18:23
openclose