QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674720#6736. Alice and BobwysunWA 0ms3584kbC++14849b2024-10-25 17:18:362024-10-25 17:18:36

Judging History

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

  • [2024-10-25 17:18:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-10-25 17:18:36]
  • 提交

answer

#include <iostream>
#include<vector>

using namespace std;

using i64 = long long;
const int P = 998244353;

int power(int a, int b)
{
    int res = 1; 
    while(b)
    {
    	if(b & 1) res = (i64)res * a % P;
    	a = (i64)a * a % P;
    	b >>= 1;
	}
	
	return res;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
    int n;
    cin >> n;
    
    vector<int> fac(n + 1), invfac(n + 1);
    fac[0] = 1;
    for (int i = 1; i <= n; i ++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	
	invfac[n] = power(fac[n], P - 2);
	for(int i = n - 1; i > 0; i --)
		invfac[i] = 1ll * invfac[i + 1] * (i + 1) % P;
    
    int ans = 0;
    for (int i = 1; n - i >= i - 1; i++)
        ans = (ans + 1LL * fac[n - i] * invfac[n - i - (i - 1)] % P * fac[n - i]) % P;
    
    cout << ans << endl;
    
    return 0;
}

詳細信息

Test #1:

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

input:

1

output:

0

result:

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