-
Notifications
You must be signed in to change notification settings - Fork 1
/
The_Real_Probability.cpp
75 lines (64 loc) · 1.37 KB
/
The_Real_Probability.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Problem Name = The Real Probability
Problem Link = http://www.codechef.com/problems/MPROB
User = soumyadeep9
*/
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <limits>
#include <bitset>
#include <time.h>
#include <cmath>
#include <vector>
#include <string>
#include <set>
using namespace std;
#define MOD 1000000007LL
#define LL long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
#define SIZE 100001
int main()
{
int t;
long long a,b,c;
scanf("%d",&t);
REP(i,t)
{
double p;
scanf("%lld %lld %lld",&a,&b,&c);
if (a==0 && b ==0)
p = 1.0;
else if (a==0 && b!=0)
{
if(b<c)
p=1.0;
else p = double(c/b);
}
else if (b==0 && a!=0)
{
if(a<c)
p=1.0;
else p = double(c/a);
}
else if(c>b && c>a && c<(a+b))
p = double(1.0 - ((0.5*(a+b-c)*(a+b-c))/((double)(a*b))));
else if (c<=a && c<=b)
p = double(c*c/(2.0*a*b));
else if (b<=c && c<a)
p = double((c*c)-((c-b)*(c-b)))/(2.0*a*b);
else if (a<c && c<b)
p = double((c*c)-((c-a)*(c-a)))/(2.0*a*b);
else if((a+b)<=c)
p = 1.0;
printf("%lf\n",p);
}
return 0;
}