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 ...
随机推荐
- 转载:浅析Java中的final关键字
谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关键字.另外,Java中的String类就是一个final类,那么今天我们就来了解final这个关键字的用法.下 ...
- 【转】linux中wait与waitpid的差别
原文网址:http://blog.163.com/libo_5/blog/static/15696852010324287748/ zombie不占用内存也不占用CPU,表面上我们可以不用在乎它们的存 ...
- 常用的css的技巧
1.在做项目当中,由静态页面来载入到项目中,作为动态数据的部分,若是这个动态数据,前面或者后面有需要图片显示(图片是用background来显示的),一般不用float:left或者right,而是p ...
- 屏蔽页面js报的错误
有时候,某些js的错误,确实没有什么大影响,但是这个又实在没办法. 一般,下下策采取 <script language="javascript"> function k ...
- iOS - GIF图的完美拆解、合成、显示
转:http://blog.csdn.net/marujunyy/article/details/14455699 最近由于项目需要,需要先把gif图拆解开,然后在每一张图片上添加一些图片和文字,最后 ...
- C#+AE 用MapControl加载栅格格式文件
需要引入DataSourceRaster命名空间. 具体步骤如下: ①:利用工作控件工厂抽象类定义接口变量,利用工作空间工厂的子类RatserWorkspaceFactory对应的组件类RasterW ...
- 手势解锁自定义View
package com.rxx.view; import java.util.ArrayList; import java.util.List; import java.util.Timer; imp ...
- LoadRunner检查点实战
码农博客 即将到期,现将博客中部分文章转载到博客园.转载时略有删减. 一.为什么要使用检查点 为什么要使用检查点,那就要说明一下LR如何判断脚本是否执行成功. LR判断脚本是否执行成功是根据服务器返回 ...
- Cocos2d-x使用iOS游戏内付费IAP(C++篇)
本文章转载 http://www.ityran.com/archives/5515.非本人原创! 前期准备 设备与账号 在开始编码之前我们需要准备测试环境. IAP只能真机测试,准备一台iOS设备是必 ...
- 对Spring的理解
1.Spring实现了工厂模式的工厂类,这个类名为BeanFactory实际上是一个接口,在程序中通常BeanFactory的子类ApplicationContext.Spring相当于一个大的工厂类 ...