QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#490939#8635. 圆KiharaTouma#20 12ms3976kbC++23551b2024-07-25 16:48:072024-07-25 16:48:09

Judging History

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

  • [2024-07-25 16:48:09]
  • 评测
  • 测评结果:20
  • 用时:12ms
  • 内存:3976kb
  • [2024-07-25 16:48:07]
  • 提交

answer

//qoj8635
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 5010;
const ll P = 998244353;
int n;
ll f[N];

ll qp(ll x, ll y){
	ll ans = 1;
	while(y){
		if(y & 1){
			ans = ans * x % P;
		}
		x = x * x % P;
		y >>= 1;
	}
	return ans;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		ll tmp = 0;
		for(int j = 0; j <= i + 1; ++ j){
			tmp += f[max(0, j-2)] + f[max(0, i-j-1)];
		}
		f[i] = tmp * qp(i+2, P-2) % P + 1;
	}
	printf("%lld\n", (f[n-3] + 1) % P);
	return 0;
}

详细


Pretests


Final Tests

Test #1:

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

input:

3

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

4

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3800kb

input:

6

output:

3

result:

wrong answer 1st numbers differ - expected: '299473309', found: '3'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 3880kb

input:

10

output:

5

result:

wrong answer 1st numbers differ - expected: '487238321', found: '5'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 3880kb

input:

100

output:

-90875623

result:

wrong answer 1st numbers differ - expected: '41620761', found: '-90875623'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3952kb

input:

200

output:

-923055229

result:

wrong answer 1st numbers differ - expected: '208771764', found: '-923055229'

Test #7:

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

input:

500

output:

-515344982

result:

wrong answer 1st numbers differ - expected: '888621375', found: '-515344982'

Test #8:

score: 0
Wrong Answer
time: 11ms
memory: 3920kb

input:

4798

output:

952533544

result:

wrong answer 1st numbers differ - expected: '319137015', found: '952533544'

Test #9:

score: 0
Wrong Answer
time: 12ms
memory: 3976kb

input:

4999

output:

-655131513

result:

wrong answer 1st numbers differ - expected: '818467659', found: '-655131513'

Test #10:

score: 0
Wrong Answer
time: 12ms
memory: 3824kb

input:

5000

output:

-443461705

result:

wrong answer 1st numbers differ - expected: '142907477', found: '-443461705'