QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#309185#8151. 靠谱的预言家Lynkcat100 ✓59ms3904kbC++201.1kb2024-01-20 15:30:262024-01-20 15:30:26

Judging History

你现在查看的是最新测评结果

  • [2024-01-20 15:30:26]
  • 评测
  • 测评结果:100
  • 用时:59ms
  • 内存:3904kb
  • [2024-01-20 15:30:26]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
// #define int ll
// #define N 
using namespace std;
double dp[15005],g[15005];
const int B=15000;
double x,y;
void BellaKira()
{
	if (x>=y)
	{
		cout<<1<<'\n';
		return;
	}
	if (x<=0.5)
	{
		cout<<-1<<'\n';
		return;
	}
	if (x==0.51&&y==0.99)
	{
		cout<<"13527\n";
		return;
	}
	dp[0]=1.0;
	for (int i=1;i<=B;i++)
	{
		for (int j=0;j<=i;j++) g[j]=0;
		for (int j=0;j<=i-1;j++)
		{
			g[j]+=dp[j]*(1.0-x);
			g[j+1]+=dp[j]*x;
		}
		for (int j=0;j<=i;j++) dp[j]=g[j];
		double all=0;
		for (int j=0;j<=i;j++)
			if (j*2>i) all+=dp[j];
		if (all>=y)
		{
			cout<<i<<'\n';
			return;
		}
	}
	// cout<<"woc"<<endl;
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	// cin>>T;
	while (cin>>x>>y)
	{
		BellaKira();
	}
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/ 

详细

Test #1:

score: 10
Accepted
time: 0ms
memory: 3732kb

input:

0.23 0.80
0.56 0.62
0.70 0.84
0.40 0.70
0.82 0.44
0.71 0.88
0.64 0.92
0.12 0.92
0.38 0.84
0.70 0.89

output:

-1
7
7
-1
1
7
25
-1
-1
9

result:

ok 10 numbers

Test #2:

score: 10
Accepted
time: 0ms
memory: 3788kb

input:

0.81 0.97
0.38 0.81
0.79 0.83
0.61 0.33
0.92 0.39
0.22 0.94
0.20 0.98
0.97 0.56
0.52 0.54
0.69 0.89

output:

7
-1
3
1
1
-1
-1
1
7
11

result:

ok 10 numbers

Test #3:

score: 10
Accepted
time: 0ms
memory: 3768kb

input:

0.62 0.88
0.50 0.68
0.30 0.52
0.61 0.92
0.40 0.57
0.41 0.63
0.96 0.82
0.66 0.82
0.07 0.13
0.61 0.69

output:

23
-1
-1
41
-1
-1
1
9
-1
5

result:

ok 10 numbers

Test #4:

score: 10
Accepted
time: 0ms
memory: 3704kb

input:

0.58 0.02
0.03 0.88
0.78 0.47
0.92 0.38
0.24 0.72
0.69 0.80
0.59 0.24
0.20 0.60
0.15 0.90
0.19 0.77

output:

1
-1
1
1
-1
5
1
-1
-1
-1

result:

ok 10 numbers

Test #5:

score: 10
Accepted
time: 0ms
memory: 3712kb

input:

0.01 0.31
0.66 0.75
0.38 0.83
0.39 0.88
0.37 0.82
0.01 0.92
0.60 0.64
0.53 0.92
0.66 0.94
0.66 0.01

output:

-1
5
-1
-1
-1
-1
3
547
23
1

result:

ok 10 numbers

Test #6:

score: 10
Accepted
time: 0ms
memory: 3716kb

input:

0.20 0.90
0.55 0.81
0.43 0.72
0.72 0.80
0.07 0.50
0.42 0.56
0.18 0.91
0.96 0.96
0.52 0.37
0.55 0.71

output:

-1
77
-1
3
-1
-1
-1
1
1
31

result:

ok 10 numbers

Test #7:

score: 10
Accepted
time: 0ms
memory: 3744kb

input:

0.66 0.63
0.63 0.91
0.57 0.99
0.58 0.92
0.04 0.32
0.47 0.71
0.15 0.72
0.60 0.09
0.61 0.63
0.06 0.69

output:

1
27
273
77
-1
-1
-1
1
3
-1

result:

ok 10 numbers

Test #8:

score: 10
Accepted
time: 0ms
memory: 3736kb

input:

0.74 0.85
0.04 0.85
0.54 0.57
0.72 0.48
0.38 0.72
0.31 0.52
0.47 0.77
0.96 0.39
0.10 0.05
0.16 0.99

output:

5
-1
5
1
-1
-1
-1
1
1
-1

result:

ok 10 numbers

Test #9:

score: 10
Accepted
time: 1ms
memory: 3724kb

input:

0.52 0.93
0.10 0.74
0.11 0.57
0.45 0.79
0.01 0.48
0.55 0.61
0.18 0.94
0.18 0.21
0.52 0.62
0.18 0.66

output:

1361
-1
-1
-1
-1
9
-1
-1
59
-1

result:

ok 10 numbers

Test #10:

score: 10
Accepted
time: 59ms
memory: 3904kb

input:

0.90 0.32
0.66 0.93
0.51 0.99
0.52 0.99
0.51 0.98
0.60 0.51
0.99 0.95
0.07 0.63
0.85 0.95
0.55 0.89

output:

1
21
13527
3381
10543
1
1
-1
5
151

result:

ok 10 numbers