QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#64544#3083. Bit Operationhsl2363WA 53ms34444kbC++141.4kb2022-11-24 23:33:382022-11-24 23:33:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-24 23:33:41]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:34444kb
  • [2022-11-24 23:33:38]
  • 提交

answer

#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
//#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e6 + 5, Mod = 9982445353;
const double Pi = acos(-1);
typedef ll arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	ll res = 0, sign = 1;
	char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
ll n;
ll ans;
arr a, f, fac, inv, invfac;
ll C(ll x, ll y) { return fac[x] * invfac[y] % Mod * invfac[x - y] % Mod; }
int main()
{
	f[0] = f[1] = 1;
	fac[0] = fac[1] = inv[1] = invfac[0] = invfac[1] = 1;
	for (ll i = 2; i <= 1000000; i++)
	{
		f[i] = f[i - 1] * (2 * i - 1) % Mod;
		fac[i] = fac[i - 1] * i % Mod;
		inv[i] = Mod - Mod / i * inv[Mod % i] % Mod;
		invfac[i] = invfac[i - 1] * inv[i] % Mod;
	}
	cin >> n;
	for (ll i = 1; i <= n; i++)
		if (read())
		{
			if (i == 1 || i == n)
				ans = Add(ans, f[n - 1]);
			else
				ans = Add(ans, f[i - 1] * f[n - i] % Mod * C(n - 1, i - 1) % Mod);
		}
	cout << ans << '\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 53ms
memory: 34444kb

input:

999993
1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1...

output:

921287004

result:

wrong answer 1st lines differ - expected: '318158140', found: '921287004'