Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/312/problem/B
Description
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is
for SmallR while
for Zanoes. The one who shoots in the target first should be the winner.
Output the probability that SmallR will win the match.
Input
A single line contains four integers
.
Output
Print a single real number, the probability that SmallR will win the match.
The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.
Sample Input
1 2 1 2
Sample Output
0.666666666667
HINT
题意
第一个人有a/b的概率射中靶子,第二个人有c/d的概率射中靶子,两个人轮流射
然后问你有多大的概率第二个人最先射中靶子
题解:
水题啦,很容易推公式,发现是一个等比数列,然后求和就好了
也可以不求和,直接暴力for也行
代码:
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std; int main()
{
double a,b,c,d;
cin>>a>>b>>c>>d;
double p1 = a/b,p2 = c/d;
double ans = ;
double p = ;
for(int i=;i<;i++)
{
ans += p*(-p1)*p2;
p = p * (-p1) * (-p2);
}
printf("%.10f\n",-ans);
}
Codeforces Round #185 (Div. 2) B. Archer 水题的更多相关文章
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
- Codeforces Round #338 (Div. 2) A. Bulbs 水题
A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...
- Codeforces Round #282 (Div. 1) A. Treasure 水题
A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
随机推荐
- ActionBarSherlock的学习笔记(四) ------------ ActionBarSherlock中的搜索及SearchView的使用
在使用ActionBarSherlock定义app的头部操作时,会经常看见搜索的动作,本文主要介绍一下搜索是如何实现的. 1. SearchView 是搜索的核心组件,具体介绍请参考Android官方 ...
- 【RMQ问题】求数组区间最大值,NYOJ-1185-最大最小值
转自:http://blog.csdn.net/lilongherolilong/article/details/6624390 先挖好坑,明天该去郑轻找虐 RMQ(Range Minimum/Max ...
- Delphi EVariantTypeCastError错误的解决方法
在执行程序的时候总是提示: ---------------------------Debugger Exception Notification---------------------------P ...
- Android 生成含签名文件的apk安装包
做android开发时,必然需要打包生成apk文件,这样才能部署.作为一个完善的apk,必然少不了签名文件,否则下次系统无法进行更新. 一.签名文件的制作及打包生成APK文件 签名文件比较流行的制作方 ...
- 开源Jabber(XMPP) IM服务器介绍
一.摘要 这是我粗略读了一遍Jabber协议和相关技术文章后的产物,有些地方不一定准确.在文章中引用的一些代码来自www.jabber.org上的文章. 二. 什么是Jabber Jabber就 ...
- Delphi 2010
Delphi 2010已早由Embarcadero公司发布.作者Kim Madsen作为一名资深的Delphi开发者,在他的博客中谈到了Delphi 2010的新性能.它的使用感受以及对Delphi语 ...
- 软件测试技术(二)——使用等价类划分的方法进行的UI测试
测试的目标程序 程序代码 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; impo ...
- web自动化框架之四测试报告的搭建
现状: 看过前面的文章,楼主用的是python,所以在搭建测试报告这块的时候使用的是unittest+htmlTestRunner:然后发现生成出来的报告,总是有那么不完美的地方,比如想增加图片,比如 ...
- QC开发只能修改指派给自己的缺陷,而其他的bug可以查看但是不允许修改
今天在QC9.0项目中增加了几个项目,然后我的想法是:开发只能修改指派给自己的缺陷,而其他的bug可以查看但是不允许修改 虽说qc我还是比较熟悉的,但是对于这个问题,感觉可能要用到脚本,对于脚本我一窍 ...
- CentOS6.2编译安装codelite5.3
这两天实验室要求在服务器上安装一个codelite,于是由我对服务器下手,上网看了下悲剧的发现codelite不支持在centos上直接安装,只能编译安装,经过一番折腾之后,成功的装上了,下面是我的安 ...