hdu1085

maksyuki 发表于 oj 分类,标签:
0

Holding Bin-Laden Captive!

Problem Description

We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long time. But recently, it is reported that he hides in Hang Zhou of China! 阅读全文 »

hdu1075

maksyuki 发表于 oj 分类,标签:
0

What Are You Talking About

Problem Description

Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into English. Can you help him?

Input

The problem has only one test case, the test case consists of two parts, the dictionary part and the book part. The dictionary part starts with a single line contains a string "START", this string should be ignored, then some lines follow, each line contains two strings, the first one is a word in English, the second one is the corresponding word in Martian's language. A line with a single string "END" indicates the end of the directory part, and this string should be ignored. The book part starts with a single line contains a string "START", this string should be ignored, then an article written in Martian's language. You should translate the article into English with the dictionary. If you find the word in the dictionary you should translate it and write the new word into your translation, if you can't find the word in the dictionary you do not have to translate it, and just copy the old word to your translation. Space(' '), tab('\t'), enter('\n') and all the punctuation should not be translated. A line with a single string "END" indicates the end of the book part, and that's also the end of the input. All the words are in the lowercase, and each word will contain at most 10 characters, and each line will contain at most 3000 characters.

Output

In this problem, you have to output the translation of the history book.

Sample Input

START

from fiwo

hello difh

mars riwosf

earth fnnvk

like fiiwj

END

START

difh, i'm fiwo riwosf.

i fiiwj fnnvk!

END

Sample Output

hello, i'm from mars.

i like earth!

Hint Huge input, scanf is recommended.

Author

Ignatius.L

 

题目类型:trie

算法分析:将外文单词插入到Trie树中,每个终止节点额外存储一个对应的英文单词,然后在文本中找到一个字符串ss,然后判断其是否在Trie树中,不在就直接输出ss,否则就输出这个终止节点所对应的英文单词

 

hdu1042

maksyuki 发表于 oj 分类,标签:
0

N!

Problem Description

Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! 阅读全文 »

hdu1028

maksyuki 发表于 oj 分类,标签:
0

Ignatius and the Princess III

Problem Description

"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.

"The second problem is, given an positive integer N, we define an equation like this:
N=a[1]+a[2]+a[3]+...+a[m];
a[i]>0,1<=m<=N;
My question is how many different equations you can find for a given N.
For example, assume N is 4, we can find:
4 = 4;
4 = 3 + 1;
4 = 2 + 2;
4 = 2 + 1 + 1;
4 = 1 + 1 + 1 + 1;
so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"

Input

The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.

Output

For each test case, you have to output a line contains an integer P which indicate the different equations you have found.

Sample Input

4

10

20

Sample Output

5

42

627

Author

Ignatius.L

 

题目类型:整数的拆分

算法分析:直接使用普通母函数将其转换成求解多项式乘法的问题,然后直接输出coeff[n]的值即可

 

hdu1025

maksyuki 发表于 oj 分类,标签:
0

Constructing Roads In JGShining's Kingdom

Problem Description

JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines. 阅读全文 »

hdu1023

maksyuki 发表于 oj 分类,标签:
0

Train Problem II

Problem Description

As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway. 阅读全文 »

hdu1009

maksyuki 发表于 oj 分类,标签:
0

FatMouse' Trade

Problem Description

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.
The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.

Input

The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. All integers are not greater than 1000.

Output

For each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain.

Sample Input

5 3

7 2

4 3

5 2

20 3

25 18

24 15

15 10

-1 -1

Sample Output

13.3333

1.500

Author

CHEN, Yue

Source

ZJCPC2004

 

题目类型:贪心

算法分析:直接算出每一种物品的价值/花费,然后按其从大到小排序。最后对于给定的背包的容量,尽量将单位价值高的物品放入。注意本题的坑点是精度!!!!!!

 

hdu1005

maksyuki 发表于 oj 分类,标签:
0

Number Sequence

Problem Description

A number sequence is defined as follows:

f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.

Given A, B, and n, you are to calculate the value of f(n). 阅读全文 »

hdu1004

maksyuki 发表于 oj 分类,标签:
0

Let the Balloon Rise

Problem Description

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.
This year, they decide to leave this lovely job to you.

Input

Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

Output

For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input

5

green

red

blue

red

red

3

pink

orange

pink

0

Sample Output

red

pink

Author

WU, Jiazhi

Source

ZJCPC2004

 

题目类型:map/Trie

算法分析:直接建立一个映射字符串的数据结构,然后统计次数即可,这里分别使用STL中的map和Trie树

 

 

hdu1003

maksyuki 发表于 oj 分类,标签:
0

Max Sum

Problem Description

Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), 阅读全文 »