I haven't completed my questions for more than a year. Today I have made a water question for the competition. I feel the question is bitter and hard to understand.
Then, I read it several times, understood and thought, and achieved results.
There are two writable points:
1: Derivation, composition of the expected ans: First mean + undetermined mean
That is, ANS = (A1 +... An)/n + ans * M/N
Final Result: ANS = (A1 + .. An)/(n-M );
The formula also shows n! = M. The question can also be n = m. It is INF.
2: The accuracy problem. I used to make this mistake, but it was all vague. I paid special attention to it this time.
When judging sum = 0, use int to define sum to judge. AC, use double to judge expected
The most familiar wrong Anser...
The author also explained it in a little bit, providing two connections for everyone to learn. One is Microsoft's official materials.
A blog of step home
Http://technet.microsoft.com/zh-cn/library/system.double
Http://www.jb51.net/article/36935.htm
Do not spray a small white code ~ HA:
#include <stdio.h>int main(){ int n,m; double ans; while(scanf("%d",&n)==1) { int sum=0; for(int i=0;i<n;i++) { int temp; scanf("%d",&temp); sum+=temp; } scanf("%d",&m); for(int i=0;i<m;i++) { int temp; scanf("%d",&temp); } if(sum==0) { printf("0.00\n");continue; } if(n==m) { printf("inf\n");continue; } ans=(double)sum/(n-m); printf("%.2lf\n",ans); } return 0;}
Record a few URLs that are not carefully viewed:
Http://book.51cto.com/art/201204/326994.htm
Blog.csdn.net/xiaozzhao/article/details/7450042
Http://blog.csdn.net/sgnaw/article/details/12442