CodeForces 312B Archer

Archer

Time Limit: 2000ms

Memory Limit: 262144KB

This problem will be judged on CodeForces. Original ID: 312B
64-bit integer IO format: %I64d      Java class name: (Any)

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

Input

1 2 1 2

Output

0.666666666667

Source

Codeforces Round #185 (Div. 2)

解题:等比数列求和的极限

1 #include <bits/stdc++.h>
2 using namespace std;
3 int a,b,c,d;
4 int main(){
5     while(~scanf("%d%d%d%d",&a,&b,&c,&d))
6         printf("%.8f\n",(double)a*d/(a*d+b*c-c*a));
7     return 0;
8 }

时间: 2024-10-04 11:01:48

CodeForces 312B Archer的相关文章

CodeForces 78D Archer&#39;s Shot

二分. 统计过程如下图: 先统计红线上的个数,然后统计绿线上的个数,然后统计咖啡色线上的个数......一个一个往下跳就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #inclu

【CodeForces 312B】BUPT 2015 newbie practice #3A Archer

题 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 tar

Codeforces 594A - Warrior and Archer

题目大意:给你在一条线上的n(偶数)个点,mike和alice 开始禁点,他们轮流开始,直到最后只剩下两个点, mike希望剩下的两个点距离尽可能小,alice希望剩下的两个点距离尽可能大,他们都采用最优策略,问你最后 剩下的两个点是什么. 这种脑洞题好难啊啊,难受. 思路:我们假定剩下了两个点是 x1 和 x2 ,那么最优考虑,mike拿掉的是<x1 和 >x2的点,alice拿掉的是 x1 和 x2 之间的点,所以我们枚举x1 和 x2,因为mike先选,我们取其中的最小值. #inclu

codeforces 的20道C题

A - Warrior and Archer CodeForces - 595C n  偶数  然后n个数字 A B 轮流取一个 A让差变小B让差变大 直到最后2 个   求的是最小剩下的差 最后剩下的 L R  相距 n/2    求一下最小的就行 #include <iostream> #include <cstdio> #include <cmath> #include <map> #include <algorithm> #include

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多

Codeforces 124A - The number of positions

题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing b

Codeforces 841D Leha and another game about graph - 差分

Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or  - 1. To pass th

Codeforces Round #286 (Div. 1) A. Mr. Kitayuta, the Treasure Hunter DP

链接: http://codeforces.com/problemset/problem/506/A 题意: 给出30000个岛,有n个宝石分布在上面,第一步到d位置,每次走的距离与上一步的差距不大于1,问走完一路最多捡到多少块宝石. 题解: 容易想到DP,dp[i][j]表示到达 i 处,现在步长为 j 时最多收集到的财富,转移也不难,cnt[i]表示 i 处的财富. dp[i+step-1] = max(dp[i+step-1],dp[i][j]+cnt[i+step+1]) dp[i+st

Codeforces 772A Voltage Keepsake - 二分答案

You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power store