QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178049#5377. $N$ 门问题zhoukangyang#5 1ms7972kbC++111.2kb2023-09-13 17:40:352024-07-04 01:56:23

Judging History

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

  • [2024-07-04 01:56:23]
  • 评测
  • 测评结果:5
  • 用时:1ms
  • 内存:7972kb
  • [2023-09-13 17:40:35]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define ull unsigned long long 
#define sz(a) ((int) a.size())
#define vi vector<int>
#define me(a, x) memset(a, x, sizeof(a))
using namespace std;
const int N = 1 << 21, L = 5e5, mod = 998244353;

double f[N];

ll n;

int k;
ll a[N], b[N];
ll rd() {
	cin >> k;
	L(i, 1, k) {
		cin >> a[i] >> b[i];
	}
	n = 0;
	while(true) {
		int win = 1;
		L(i, 1, k) {
			if(n % b[i] != a[i]) {
				win = 0;
				break;
			}
		}
		if(win) break;
		++n;
		if(n > 200) {
			n = 0;
			break;
		}
	}
	return n;
}

int main () { 
	ios :: sync_with_stdio(false);
	cin.tie (0); cout.tie (0);
	n = rd();
	if(n < 2) {
		cout << "error\n";
		return 0;
	}
	L(i, 1, n) {
		f[i] = 1;
	}
	R(t, n, 3) {
		sort(f + 2, f + t + 1);
		reverse(f + 2, f + t + 1);
		double sum1 = 0, sum2 = 0;
		L(i, 2, t - 1) 
			sum1 += f[i];
		sum2 = sum1 + f[t];
		L(i, 2, t - 1) 
			f[i] *= sum2 / sum1;
		sort(f + 1, f + t + 1);
		reverse(f + 1, f + t + 1);
	}
	cout.precision(6); cout << fixed;
	cout << max(f[1], f[2]) / n << '\n';
	return 0;
}

/*
(n-1)/(n-2) 1 [(n-1)/(n-2)] (n-1)/(n-2) (n-1)/(n-2) x 
*/

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 7904kb

input:

1
2 3

output:

0.500000

result:

ok single line: '0.500000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 7972kb

input:

1
3 5

output:

0.666667

result:

ok single line: '0.666667'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7904kb

input:

1
4 5

output:

0.625000

result:

ok single line: '0.625000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 7736kb

input:

1
0 4

output:

error

result:

ok single line: 'error'

Test #5:

score: 0
Accepted
time: 0ms
memory: 7804kb

input:

1
1 3

output:

error

result:

ok single line: 'error'

Subtask #2:

score: 0
Wrong Answer

Test #6:

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

input:

8
1 160005726539569
1 233
0 1
1 2947295521
1 686719856393
1 54289
1 12649337
1 37281334283719577

output:

error

result:

ok single line: 'error'

Test #7:

score: 0
Accepted
time: 1ms
memory: 7868kb

input:

10
2 64
0 2
2 512
2 4
2 32
2 16
2 256
0 1
2 8
2 128

output:

0.500000

result:

ok single line: '0.500000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 7776kb

input:

10
3 256
3 16
0 1
3 8
3 512
3 32
3 4
3 128
3 64
1 2

output:

0.666667

result:

ok single line: '0.666667'

Test #9:

score: 0
Accepted
time: 1ms
memory: 7904kb

input:

10
0 2
4 8
0 4
4 256
0 1
4 512
4 32
4 128
4 64
4 16

output:

0.625000

result:

ok single line: '0.625000'

Test #10:

score: -10
Wrong Answer
time: 1ms
memory: 7912kb

input:

10
5 128
5 32
5 16
1 4
0 1
5 64
5 256
5 512
1 2
5 8

output:

0.633333

result:

wrong answer 1st lines differ - expected: '0.466667', found: '0.633333'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #57:

score: 0
Wrong Answer
time: 1ms
memory: 7712kb

input:

15
15 17
2 3
5 31
4 5
12 29
38 41
3 11
44 47
16 23
11 19
6 13
3 37
1 2
21 43
5 7

output:

error

result:

wrong answer 1st lines differ - expected: '0.000000', found: 'error'

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%