codeforces Expecting Trouble
link:http://codeforces.com/contest/345/problem/A
写完这道题目才发现这场比赛只能用Ada语言提交==
好吧,逗我玩呢
考的是数学期望公式,二项分布的期望E=np
C++代码:(我可不会Ada……=_=)
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
using namespace std;
int main(void)
{
];
double p;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
while (~scanf("%s%lf", a, &p))
{
int len = strlen(a);
;
;
; i < len; ++i)
{
') cnt++;
else if (a[i] == '?') cnt1++;
}
double Cnt = (double)cnt + p * (double)cnt1;
printf("%.5lf\n", Cnt/(double)len);
}
;
}
从今天起,每天一到两题。
codeforces Expecting Trouble的更多相关文章
- Codeforces Round #648 (Div. 2) B. Trouble Sort
一开始读错题了...想当然地认为只能相邻元素交换...(然后换了两种写法WA了4发,5分钟切A的优势荡然无存) 题目链接:https://codeforces.com/contest/1365/pro ...
- Codeforces 593B Anton and Lines
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output st ...
- CodeForces 148B Escape
Escape Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- Codeforces Round #329 (Div. 2) B. Anton and Lines 逆序对
B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/pr ...
- [刷题]Codeforces 794C - Naming Company
http://codeforces.com/contest/794/problem/C Description Oleg the client and Igor the analyst are goo ...
- Codeforces Round #408 (Div. 2)(A.水,B,模拟)
A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- [Codeforces 864E]Fire
Description Polycarp is in really serious trouble — his house is on fire! It's time to save the most ...
- Codeforces Round #408 (Div. 2) A B C 模拟 模拟 set
A. Buying A House time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- CodeForces - 796B-Find The Bone(模拟)
Zane the wizard is going to perform a magic show shuffling the cups. There are n cups, numbered from ...
随机推荐
- 【初级】linux rm 命令详解及使用方法实战
rm:删除命令 前言: windows中的删除命令大家都不陌生,linux中的删除命令和windows中有一个共同特点,那就是危险,前两篇linux mkdir 命令详解及使用方法实战[初级]中我们就 ...
- ie8 window.open导出文件报错
js创建一个<a>元素hiddenElementhiddenElement.setAttribute('href','')hiddenElement.setAttribute('targe ...
- java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException
问题描述: 严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing abort ...
- XPath
XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言的子集)文档中某部分位置的语言.XPath基于XML的树状结构,提供在数据结构树中找寻节点的能力. XPath的需要理解的相关概念 ...
- 【转】silverlight telerik RadGridView 列头显示其他控件
<telerik:GridViewDataColumn DataMemberBinding="{Binding target_id}" IsFilterable=" ...
- The Nine Indispensable Rules for HW/SW Debugging 软硬件调试之9条军规
I read this book in the weekend, and decided to put the book on my nightstand. It's a short and funn ...
- 《Linux内核分析》实验一
陈智威,<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 课堂学习笔记: 作业截图: 汇编代码堆栈分析: ...
- C++Promise函数
Promise内部会建立一个shared state是用来放一个相应的类型的值或是一个异常,并可被future object 取其数据当线程结果 promise是在形成成果后才将结果放进shared ...
- SE1-soc入手又有的东西可以玩了
笔者之前只有DE2-35 和DE2-70 两个板子用,相比之下亮点主要是:配备了DDR3 的存储器,视频处理能处理更高帧频和画幅数了,此外直接有了USB2.0接口,还配有A9 Arm双核芯片,功能一下 ...
- CRYPTO-MD5
这是昨天WHUCTF比赛的一道题目,本属于crypto,其实和crypto没多大关系, 比赛时其实差不多有这种思路了,但不相信自己,就没这样做下去,回来之后,照做了,果然是这样 链接:http://p ...