2011ACM福州网络赛第一题 A Card Game(水题)
2011-10-07 14:24
309 查看
A Card Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4 Accepted Submission(s): 3
[align=left]Problem Description[/align]
There are N cards on the table, whose front side is writen one integer number from 1 to M. We call one card "a type k card" if its number is k. The quantity of type i cards is a_i.
Let's play a game with these cards. We divide these cards into M piles by random with the only constrains that the quantity of cards in i-th (indexed from 1) pile must exactly be a_i. The possbility of each card appears in i-th pile is directly proportional to the size of this pile. That is to say, if the size of a pile is A, the possibility for each card appears in this pile is A/N assuming that N is the amount of all cards. We choose pile 1 to start the game. Assuming the we now play this game at pile k, we randomly choose a card from pile k with the same possibility for all cards in it, remember the number written on this card and throw it away. If the number on the chosen card is j, we continue this game at pile j on next round. The game terminates when we are going to get a card from an empty pile.
Now the question is, when the game ends, what is the possibility that all piles are empty?
[align=left]Input[/align]
There is only one input file. The first line is the number of test cases T. T cases follow, each of which contains two lines. The first line is an integer M (1 <= M <= 100), the number of type of cards (and the number of piles, they are exactly the same). The second line contains M positive integers not greater than 1000, the i-th number of which is a_i.
[align=left]Output[/align]
For each test case, output the possibility you are required to calculate. Answers are rounded to 6 numbers after the decimal point.(as shown in the sample output)
[align=left]Sample Input[/align]
2 1 5 2 1 2
[align=left]Sample Output[/align]
Case 1: 1.000000 Case 2: 0.333333
水题,看代码:
这样的题目很爽!
#include<stdio.h> int main() { int T; int iCase=0; int a; int n; int ans,res; scanf("%d",&T); while(T--) { iCase++; scanf("%d",&n); scanf("%d",&ans); res=ans; for(int i=1;i<n;i++) { scanf("%d",&a); res+=a; } printf("Case %d: %.6lf\n",iCase,(double)ans/res); } return 0; }
相关文章推荐
- Random Sequence 2011ACM福州赛区网络赛
- ACM/ICPC 2011 福州赛区现场赛第一题 (A .Xiangqi)
- 2011 ACM 福州赛区现场赛第一题 (A .Xiangqi)HDU 4121 Xiangqi by kuangbin
- 2011 ACM/ICPC 福州赛区网络赛解题报告
- HDU 4066 2011ACM福州网络赛
- hdu 4128 Running relay ——2011ACM福州赛区H题
- ACM HDU 4001 To Miss Our Children Time (2011ACM大连赛区网络赛)
- 2016 acm香港网络赛 F题. Crazy Driver(水题)
- HDU 4287 Intelligent IME 第37届ACM/ICPC天津赛区网络赛1010题 (水题)
- 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 A. Banana(连通性水题)
- HDU 4091 Zombie’s Treasure Chest(2011ACM上海赛区预选赛第一题)
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 A. Visiting Peking University(模拟水题)
- ACM HDU 4033 Regular Polygon(2011ACM四川网络赛第3题)
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
- 2011-第36届ACM/ICPC亚洲区中国大陆5个赛区主办方网络赛和现场赛时间安排
- 2011 ACM/ICPC 福州赛区现场赛8.7
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题
- hdu 4126 MST的最佳替换边 —— 2011ACM福州赛区F题
- [POJ 4001-4010][2011 Asia Fuzhou Regional Contest]2011 ACM 福州赛区现场赛题解(不断更新)
- 2011 大连网络赛 The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest 解题报告