GHIJ待补...
A.HUD5702:Solving Order
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3550 Accepted Submission(s): 2149
As a pretty special competition, many volunteers are preparing for it with high enthusiasm.
One thing they need to do is blowing the balloons.
Before sitting down and starting the competition, you have just passed by the room where the boys are blowing the balloons. And you have found that the number of balloons of different colors are strictly different.
After thinking about the volunteer boys' sincere facial expressions, you noticed that, the problem with more balloon numbers are sure to be easier to solve.
Now, you have recalled how many balloons are there of each color.
Please output the solving order you need to choose in order to finish the problems from easy to hard.
You should print the colors to represent the problems.
And as for each case, the first line is an integer n, which is the number of problems.
Then there are n lines followed, with a string and an integer in each line, in the i-th line, the string means the color of ballon for the i-th problem, and the integer means the ballon numbers.
It is guaranteed that:
T is about 100.
1≤n≤10.
1≤ string length ≤10.
1≤ bolloon numbers ≤83.(there are 83 teams :p)
For any two problems, their corresponding colors are different.
For any two kinds of balloons, their numbers are different.
There should be n strings in the line representing the solving order you choose.
Please make sure that there is only a blank between every two strings, and there is no extra blank.
题意:
将气球按数量排序从大到小输出
题解:
排序输出
#include#include <string> #include
B.HUD5703:Desert
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2586 Accepted Submission(s): 1660
Write a program to calculate how many different ways the tourist can drink up the water.
Next T lines contain the number n(1≤n≤1000000) for each test case.
Each line contains the binary number which represents number of different ways to finish up the water specified in the test case.
题意:
一共有n升水,每天必须喝正整数升,问有几种不同的方法。
既,用正整数组成n有多少种组成方法。
用二进制方式输出。
题解:
这题是打表找的规律,列出前几项之后发现f(n)=2n-1。
#include#include <string> #include
C.HDU5704:Luck Competition
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1775 Accepted Submission(s): 1087
If you are given a chance to know how many people are participating the competition and what their numbers are, calculate the highest number with the highest probability to win assuming that you're joining the competition.
Each test case begins with an integer N(1<N≤100), denoting the number of participants. And next line contains N−1 numbers representing the numbers chosen by other participants.
题意:
n个人参加比赛,每个人选择一个非负整数,谁选的数小于且最接近 这些数的平均数的2/3 ,谁就可能成为幸运者,现在已知有n个人,给出n-1个人选的数,第n个人是你,你要成为幸运者应该选择哪个数,以及你选择了这个数之后能成为幸运者的概率是多少。
题解:
根据题目我们可以推出幸运数x满足:
x≤ (x+sum)/n * 2/3 => x≤ (2*sum)/(3*n-2) 其中sum为n-1个数的和,n为n个人。
#include#include <string> #include
D.HDU5705:Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1707 Accepted Submission(s): 625
1. The angle formed by the hour hand and the minute hand is a.
2. The time may not be a integer(e.g. 12:34:56.78), rounded down(the previous example 12:34:56).
Each test case contains two lines.
The first line is the time HH:MM:SS (0≤HH<12,0≤MM<60,0≤SS<60).
The second line contains one integer a(0≤a≤180).
题意:
给出时间t和角度a,求时间t之后 时针和分针呈a°角的时刻。如果不是整数则向下取整。
题解:
我们知道时针每120秒走1°,分针每10秒走1°,既每隔120秒时针分针差11°,我们可以把a扩大11倍 a*=11。
所以我们可以从120秒开始枚举。当枚举的时间恰好时针分针差a°且大于时间t的时候得到结果,因为之前乘了11所以结果要除以11。
这里我们要注意0≤a≤180,所以当我们算的过程中的度数 b 大于180×11 时,时针和分针的实际度数为360*11-b。
#include#include <string.h> #include <string> #include
E.HDU5706:GirlCat
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1955 Accepted Submission(s): 1155
Under the influence of Kotori, many girls and cats are playing ``Hide and Seek'' together.
Koroti shots a photo. The size of this photo is n×m, each pixel of the photo is a character of the lowercase(from `a' to `z').
Kotori wants to know how many girls and how many cats are there in the photo.
We define a girl as -- we choose a point as the start, passing by 4 different connected points continuously, and the four characters are exactly ``girl'' in the order.
We define two girls are different if there is at least a point of the two girls are different.
We define a cat as -- we choose a point as the start, passing by 3 different connected points continuously, and the three characters are exactly ``cat'' in the order.
We define two cats are different if there is at least a point of the two cats are different.
Two points are regarded to be connected if and only if they share a common edge.
As for each case, the first line are two integers n and m, which are the height and the width of the photo.
Then there are n lines followed, and there are m characters of each line, which are the the details of the photo.
It is guaranteed that:
T is about 50.
1≤n≤1000.
1≤m≤1000.
∑(n×m)≤2×106.
There should be 2 integers in the line with a blank between them representing the number of girls and cats respectively.
Please make sure that there is no extra blank.
题意:
找图中有多少个girl和cat。如果连着走4步,是"girl"就是一个girl;如果连着走3步,是"cat"就是一只cat。字符可重复使用,只要有一个字符位置不同就是不同的。
题解:
可以用搜索来写,遇到g或c就搜它和它周围的字符能否组成girl或cat。
#include#include <string> #include
F.HDU5707:Combine String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 3853 Accepted Submission(s): 1048
A string c is said to be the combine string of a and b if and only if c can be broken into two subsequences, when you read them as a string, one equals to a, and the other equals to b.
For example, ``adebcf'' is a combine string of ``abc'' and ``def''.
Each test case contains three strings a, b and c (the length of each string is between 1 and 2000).
题意:
给你三个串a,b,c。将c拆成两个子序列,问能否正好拆成a,b。
题解:
这题贪心显然是不行的。我们可以用DP来写:
dp[i][j] 表示 c串前i+j个字符是否和a串的前i项以及b串的前j项匹配。
状态转移方程为:
if (i>0) {
dp[i][j] |= dp[i-1][j]&(a[i-1]==c[i+j-1]);
}
if (j>0) {
dp[i][j] |= dp[i][j-1]&(b[j-1]==c[i+j-1]);
}
#include#include <string.h> #include <string> #include
其他待补...