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 ...
随机推荐
- Swift 2.0 异常处理
转自:http://www.jianshu.com/p/96a7db3fde00 WWDC 2015 宣布了新的 Swift 2.0. 这次重大更新给 Swift 提供了新的异常处理方法.这篇文章会主 ...
- 【初级】linux cp 命令详解及使用方法实战
cp:复制文件或者目录 前言: cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一.一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不 ...
- 张小龙微信小程序演讲内容简介
1月9号,看看实际上如何
- Hadoop示例程序WordCount详解及实例(转)
1.图解MapReduce 2.简历过程: Input: Hello World Bye World Hello Hadoop Bye Hadoop Bye Hadoop Hello Hadoop M ...
- iOS 指定圆角个数
需要实现的效果很明确,只要左上和右上两个地方圆角,以前都是通过layer 直接设置四个角都变成圆角,然后我就开始了强大的搜索功能 然后我就获得了我想要的东西 技术链接:http://www.xuebu ...
- 利用QJSON将FDQuery转成JSON串
服务器要支持Http协议,打算采用Http+JSON的方式来交换数据.一开始考虑使用superobject,因为以前使用比较多,比较熟悉. 代码如下: class function FDQueryTo ...
- php+js实现分页
使用onclick传递参数时,参数为空分页无效.因此无刷新页面时可利用js重新获取input的值同样通过get地址传递到分页显示的php页面.page参数接收和传递方式必须一致为post或get. j ...
- C语言程序设计第10堂作业
一.本次课主要内容: 本次课程学习数组,一种最基本的构造类型,它是一组相同类型数据的有序集合.数组中的元素在内存中连续存放,每个元素都属于同一种数据类型,用数组名和下标可以唯一地确定数组元素: (1) ...
- jdk安装及环境变量配置
JDK是 Java 语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序.JDK是整个java开发的核心,它包含了JAVA的运行环境,JAVA工具和JAVA基础的类库. jdk下载地 ...
- Spring事务配置的五种方式(转载)
Spring配置文件中关于事务配置总是由三个组成部分,分别是DataSource.TransactionManager和代理机制这三部分,无论哪种配置方式,一般变化的只是代理机制这部分. DataSo ...