2014 NEUACM 新星赛

79 篇文章 0 订阅
31 篇文章 0 订阅



1481: Sister Wang

时间限制: 1 Sec   内存限制: 256 MB
提交: 514   解决: 115
[ 提交][ 状态][ 讨论版]

题目描述

Do you know Sister Wang?

Sister Wang is goddess and many diaosi want to know her phone number. Sister Wang doesn’t tell them her number directly. She tells them a string, contains letters,


 digits and symbols,but no blanks. And her phone number is in the string. Fushuai knows how to get the phone number. He delete the letters and symbols from the 

string, so that he gets some digits, and then he sort the digits in ascending order. In this way, Fushuai succeeds in calling Sister Wang.

输入

There are several cases. Each cases contains a string L(1<= length(L)<=20).

输出

Output Sister Wang’s phont number.

样例输入

Sist1e2r3w4a5ng

样例输出

12345

提示

来源

[ 提交][ 状态][ 讨论版]

1484: Hengheng eat noodles

时间限制: 1 Sec   内存限制: 256 MB
提交: 15   解决: 12
[ 提交][ 状态][ 讨论版]

题目描述

As we all know,Hengheng(big cow),very look forward to meizi and he often declare that he want to find a meizi.As Hengheng’s admirer, Jiajia decides to help Hengheng to achieve his dream in Christmas Day. In this day, Jiajia asks Hengheng to eat noodles with a pretty meizi(don’t ask why Jiajia didn’t chase this pretty meizi). When eating noodles, Hengheng is so excited that he wants the qq of the meizi. However, a unlucky thing happen.The pretty meizi says she won’t give Hengheng her qq unless Hengheng can solve her question. Hengheng promise without hesition.The pretty meizi picks up a noodle and say with sexy voice, “We all know a noodle has two ends,and now I has n noodles, so there are 2*n ends at all. Out of interest,I will link these ends randomly,and then I wonder the mathematical expectation of the circle I could get.” Although Hengheng is big cow, he can’t wait to get the qq so he can’t think as long as he see the pretty. So he ask Jiajia to solve the problem for him. Luckily,after 1000 ms,Jiajia give the right answer. And Hengheng got the qq successfully. Now, if you are Jiajia, could solve the problem within 1000 ms and help Hengheng get the qq.

输入

The first line is a integer t,indicate the number of cases.(t<=10)
For each case follow,there is a integer n,imply the amount of noodles.(n<=10^6)

输出

For each case, print a double E,represent the mathematical expectation.(E retain 6 decimal)

样例输入

3
1
2
4

样例输出

1.000000
1.333333
1.676190

提示


来源

[ 提交][ 状态][ 讨论版]

题意:求n条面条围成圆圈的数学期望。

解题思想:n条面条总共有2n个端点。可看做n-1条面条增加一条面条,对于增加的这条面条,我们随便选取一个端点,总共有2n-1个端点可以与之结合:
1.对于第一种情况,只能跟自己另一条边组合,故第一种情况圆圈数加一,这种概率为p1=1/(2n-1)
2.除了第一种情况就是第二种情况,圆圈数不变,这种概率为p2=(2n-2)/(2n-1)

数学规律递推公式推导(E'代表连加符号西格玛,S表示圆圈数,p表示对应的概率):
exp(n-1)=E'SjPj
exp(n)=E'(Sj+1)PjP1+E'SjPjP2
           =(E'SjPj+E'Pj)P1+E'SjPjP2
           =(exp(n-1)+1)P1+exp(n-1)P2
           =(exp(n-1)+1)*1/(2n-1)+exp(n-1)*(2n-2)/(2n-1)


AC代码:



?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
double e[1000001];
int main()
{
     int t,i,n;
     e[1]=1.000000;
     for (i=2;i<=1000001;i++)
     {
         e[i]=(e[i-1]+1.0)/(2*i-1)+e[i-1]*(2*i-2)/(2*i-1);
     }
     scanf ( "%d" ,&t);
     while (t--)
     {
         scanf ( "%d" ,&n);
         printf ( "%lf\n" ,e[n]);
     }
     return 0;
}
/**************************************************************
     Problem: 1484
     User: 1307122118
     Language: C++
     Result: 正确
     Time:119 ms
     Memory:9064 kb
****************************************************************/




?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
double e[1000001];
int main()
{
     int t,i,n;
     e[1]=1.000000;
     for (i=2;i<=1000001;i++)
     {
         e[i]=(e[i-1]+1.0)/(2*i-1)+e[i-1]*(2*i-2)/(2*i-1);
     }
     scanf ( "%d" ,&t);
     while (t--)
     {
         scanf ( "%d" ,&n);
         printf ( "%lf\n" ,e[n]);
     }
     return 0;
}
/**************************************************************
     Problem: 1484
     User: 1307122118
     Language: C++
     Result: 正确
     Time:119 ms
     Memory:9064 kb
****************************************************************/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CSDN新星创作者是CSDN平台为优秀的原创作者而设立的一个特殊身份和称号。作为CSDN新星创作者,你可以享受到更多的平台资源和关注度,以及与其他优秀作者的交流和合作机会。 想要成为CSDN新星创作者,首先需要具备一定的写作能力和原创创作的积累。你要有自己的技术领域或者研究方向,并能够进行深入的学习和研究。此外,对于新领域的探索和开拓也是非常受欢迎的。 在申请CSDN新星创作者时,你需要提交一份详细的申请材料。在申请材料中,你需要提供个人的学习和工作经历,以及所涉及的技术领域和研究方向。此外,还需要提交一篇自己的原创文章,可以是技术分享、经验总结或者创新研究等,以展示自己的写作和创作能力。 CSDN会对申请材料进行评估和筛选,选择优秀的申请者作为新星创作者。如果被选中,你将获得CSDN官方的认可和推荐,文章将被推送给更多的读者和关注者,从而提升你的影响力和知名度。 作为CSDN新星创作者,你将有更多机会与其他优秀的作者进行互动和交流,相互学习和进步。同时,CSDN还会为新星创作者提供更多的宣传和推广机会,例如邀请参与技术峰会、线下活动和专栏合作等。 总之,成为CSDN新星创作者是一个获得更多资源、关注和影响力的机会,但也需要有一定的实力和深入的技术积累。希望通过努力和创作,在CSDN平台上展现自己的价值和才华。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林下的码路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值