qdu_ACM集训队3月5号组队训练
A Alien’s Organ
There’s an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago.
Marjar is a strange alien. It needs to generate new organs(body parts) to fight. The generated organs will provide power to Marjar and then it will disappear. To fight for problem of moral integrity decay on our earth, it will randomly generate new fighting organs all the time, no matter day or night, no matter rain or shine. Averagely, it will generate λ new fighting organs every day.
Marjar’s fighting story is well known to people on earth. So can you help to calculate the possibility of that Marjar generates no more than N organs in one day?
Input
The first line contains a single integer T (0 ≤ T ≤ 10000), indicating there are T cases in total. Then the following T lines each contains one integer N (1 ≤ N ≤ 100) and one float number λ (1 ≤ λ ≤ 100), which are described in problem statement.
Output
For each case, output the possibility described in problem statement, rounded to 3 decimal points.
Sample Input
3
5 8.000
8 5.000
2 4.910
Sample Output
0.191
0.932
0.132
迫松分布,第一次遇見這中題,還特意上網(wǎng)查了查迫松分布啥意思。。
代碼如下:
Happy Programming Contest
In Zhejiang University Programming Contest, a team is called “couple team” if it consists of only two students loving each other. In the contest, the team will get a lovely balloon with unique color for each problem they solved. Since the girl would prefer pink balloon rather than black balloon, each color is assigned a value to measure its attractiveness. Usually, the boy is good at programming while the girl is charming. The boy wishes to solve problems as many as possible. However, the girl cares more about the lovely balloons. Of course, the boy’s primary goal is to make the girl happy rather than win a prize in the contest.
Suppose for each problem, the boy already knows how much time he needs to solve it. Please help him make a plan to solve these problems in strategic order so that he can maximize the total attractiveness value of balloons they get before the contest ends. Under this condition, he wants to solve problems as many as possible. If there are many ways to achieve this goal, he needs to minimize the total penalty time. The penalty time of a problem is equal to the submission time of the correct solution. We assume that the boy is so clever that he always submit the correct solution.
Input
The first line of input is an integer N (N < 50) indicating the number of test cases. For each case, first there is a line containing 2 integers T (T <= 1000) and n (n <= 50) indicating the contest length and the number of problems. The next line contains n integers and the i-th integer ti (ti <= 1000) represents the time needed to solve the ith problem. Finally, there is another line containing n integers and the i-th integer vi (vi <= 1000) represents the attractiveness value of the i-th problem. Time is measured in minutes.
Output
For each case, output a single line containing 3 integers in this order: the total attractiveness value, the number of problems solved, the total penalty time. The 3 integers should be separated by a space.
Sample Input
2
300 10
10 10 10 10 10 10 10 10 10 10
1 2 3 4 5 6 7 8 9 10
300 10
301 301 301 301 301 301 301 301 301 301
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
Sample Output
55 10 550
0 0 0
dp題目,幾乎每一次都有dp題。
這個(gè)題第一次看的時(shí)候,就覺得有點(diǎn)像01背包,但是不知道怎么弄。由于題目說是在總價(jià)值最大的時(shí)候,出題數(shù)最大,罰時(shí)最小。一開始是按價(jià)值排的序,樣例過了,然后wa了。后來按著時(shí)間有小到大排序。就過了。后來想了想,就算是不按著價(jià)值排序,在dp的時(shí)候,也還是會(huì)找到時(shí)間最大值的,但是那個(gè)時(shí)間罰時(shí)就不一定了。代碼如下
還有兩個(gè)題是隊(duì)友做的。代碼暫無
努力加油a啊,(o)/~
總結(jié)
以上是生活随笔為你收集整理的qdu_ACM集训队3月5号组队训练的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 算法训练 K好数(dp+动态规划)
- 下一篇: qdu_ACM3月7号组队训练