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 ...
随机推荐
- Delphi ORD
//Char 类型与其编码值的转换:varb: Byte;c: Char;beginb := Ord('A'); {返回: 65}b := Ord(#65); {返回: 65}b := Ord ...
- hdu3231 (三重拓扑排序) 2009 Asia Wuhan Regional Contest Hosted by Wuhan University
这道题算是我拓扑排序入门的收棺题了,卡了我好几天,期间分别犯了超时,内存溢出,理解WA,细节WA,格式WA…… 题目的意思大概是在一个三维坐标系中,有一大堆矩形,这些矩形的每条棱都与坐标轴平行. 这些 ...
- 祭奠我的csdn博客
本人在csdn的博客莫名其妙地被封了(http://blog.csdn.net/fty8788),非常郁闷. 回忆起,可能是我近半年由于工作事情忙很少写博客了,被某213盗用发了不恰当的东东.我也查不 ...
- CSS基础知识——选择器
选择器 元素选择器# 文档元素为最基本的选择器 例子:div{属性:值}; 选择器分组 例子:h2,p{属性:值}; 表示符合这两种规则的元素设置相同的属性值 通配选择器 表示所有元素 类选择器 应用 ...
- 如何利用WordPress创建自定义注册表单插件
来源:http://www.ido321.com/1031.html 原文:Creating a Custom WordPress Registration Form Plugin 译文:创建一个定制 ...
- C#冒泡排序详解
今天写一简单的冒泡排序,带有详细的中文注释,新手一定要看看! 因为这是找工作面试时经常 笔试 要考的题目. using System; using System.Collections.Generic ...
- 【暑假】[实用数据结构]UVa11991 Easy Problem from Rujia Liu?
UVa11991 Easy Problem from Rujia Liu? 思路: 构造数组data,使满足data[v][k]为第k个v的下标.因为不是每一个整数都会出现因此用到map,又因为每 ...
- java 复习003
今天主要复习下数据结构的东西 树 自平衡二叉查找树 AVL树(高平衡树)(wiki) 特性:任何节点的两个子树的高度最大差别为一 时间复杂度:查找.插入和删除在平均和最坏情况下都是O(log n) 红 ...
- 数据结构(三)实现AVL树
AVL树的定义 一种自平衡二叉查找树,中面向内存的数据结构. 二叉搜索树T为AVL树的满足条件为: T是空树 T若不是空树,则TL.TR都是AVL树,且|HL-HR| <= 1 (节点的左子树高 ...
- ERROR (ClientException)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABPwAAABCCAIAAABM0F+3AAAgAElEQVR4nO2d+29d13Xn7y+xyMvLty