hdu1114

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

Piggy-Bank

Problem Description

Before ACM can do anything, a budget must be prepared and the 阅读全文 »

hdu1087

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

Super Jumping! Jumping! Jumping!

Problem Description

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. 阅读全文 »

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), 阅读全文 »

TopCoder SRM#667(Div2)(2/3)

maksyuki 发表于 比赛 分类,标签:
2

A Problem Statement

You are given two distinct points A and B in the two-dimensional plane. Your task is to find any point C with the following properties:

C is different from A and B. 阅读全文 »

2015ACM-ICPC亚洲区长春网赛(2/13)

maksyuki 发表于 比赛 分类,
0

 

B Ponds

Problem Description

Betty owns a lot of ponds, some of them are connected with other ponds by pipes, and there will not be more than one pipe between two ponds. Each pond has a value v. Now Betty wants to remove some ponds because she does not have enough money. But each time when she removes a pond, she can only remove the ponds which are connected with less than two ponds, or the pond will explode. Note that Betty should keep removing ponds until no more ponds can be removed. After that, please help her calculate the sum of the value for each connected component consisting of a odd number of ponds

Input

The first line of input will contain a number T(1≤T≤30) which is the number of test cases. For each test case, the first line contains two number separated by a blank. One is the number p(1≤p≤104) which represents the number of ponds she owns, and the other is the number m(1≤m≤105) which represents the number of pipes. The next line contains p numbers v1,...,vp, where vi(1≤vi≤108) indicating the value of pond i. Each of the last m lines contain two numbers a and b, which indicates that pond a and pond b are connected by a pipe.

Output

For each test case, output the sum of the value of all connected components consisting of odd number of ponds after removing all the ponds connected with less than two pipes.

Sample Input

1
7 7
1 2 3 4 5 6 7
1 4
1 5
4 5
2 3
2 6
3 6
2 7

Sample Output

21

Source

2015 ACM/ICPC Asia Regional Changchun Online

 

题目类型:拓扑排序删点+DFS

算法分析:先使用链式前向星建图,然后使用拓扑排序的方法将所有不符合的点删去(标记),易知此时的连通分量都是环,然后使用DFS将所有的分量中点的数量是奇数的val和累加起来即可

 

G The Water Problem

Problem Description

In Land waterless, water is a very limited resource. People always fight for the biggest source of water. Given a sequence of water sources with a1,a2,a3,...,anrepresenting the size of the water source. Given a set of queries each containing 2 integers l and r, please find out the biggest water source between al and ar.

Input

First you are given an integer T(T≤10) indicating the number of test cases. For each test case, there is a number n(0≤n≤1000) on a line representing the number of water sources. n integers follow, respectively a1,a2,a3,...,an, and each integer is in {1,...,106}. On the next line, there is a number q(0≤q≤1000)representing the number of queries. After that, there will be q lines with two integers l and r(1≤l≤r≤n) indicating the range of which you should find out the biggest water source.

Output

For each query, output an integer representing the size of the biggest water source.

Sample Input

3
1
100
1
1 1
5
1 2 3 4 5
5
1 2
1 3
2 4
3 4
3 5
3
1 999999 1
4
1 1
1 2
2 3
3 3

Sample Output

100
2
3
4
4
5
1
999999
999999
1

Source

2015 ACM/ICPC Asia Regional Changchun Online

 

题目类型:水题

算法分析:数据比较小,所以可以直接暴力枚举

 

BestCoder Round #55(0/4)

maksyuki 发表于 比赛 分类,标签:
0

Codeforces Round #319(Div.2) (4/5) (Div.1) (2/5)

maksyuki 发表于 比赛 分类,标签:
0