QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485304#4931. Comic BingePetroTarnavskyi#WA 0ms4728kbC++201.8kb2024-07-20 16:04:272024-07-20 16:04:27

Judging History

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

  • [2024-07-20 16:04:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4728kb
  • [2024-07-20 16:04:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int mod = 235813;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}
int sub(int a, int b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}
int mult(int a, int b)
{
	return (LL)a * b % mod;
}
int binpow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = mult(res, a);
		a = mult(a, a);
		n /= 2;
	}
	return res;
}

const int N = 1 << 17;

int fact[N], ifact[N];
int C(int n, int k)
{
	if(k < 0 || k > n)
		return 0;
	return mult(fact[n], mult(ifact[k], ifact[n - k]));
}

void init()
{
	fact[0] = 1;
	FOR(i, 1, N)
		fact[i] = mult(fact[i - 1], i);
	ifact[N - 1] = binpow(fact[N - 1], mod - 2);
	RFOR(i, N, 1)
		ifact[i - 1] = mult(ifact[i], i);
	
}

const int TEN5 = 100'000;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	
	int n;
	cin >> n;
	VI a(n);
	FOR(i, 0, n)
		cin >> a[i];
	
	int val = 0;
	FOR(i, 0, n)
	{
		int coef = mult(C(n - 1, i), binpow(mod - 1, n - 1 - i));
		int x = a[i] < 0 ? a[i] + mod : a[i];
		
		val = add(val, mult(x, coef));
	}
	int ans = 0;
	FOR(i, 0, n)
	{
		int coef = mult(C(n - 1, i), binpow(mod - 1, n - 1 - i));
		int x = a[i] < 0 ? a[i] + mod : a[i];
		
		int U = sub(val, mult(x, coef));
		
		int a1 = mult(sub(0, U), binpow(coef, mod - 2));
		
		FOR(t, 0, 2)
		{
			if(-TEN5 <= a1 && a1 <= TEN5)
				ans += a1 != a[i];
		
			a1 -= mod;
		}
	}
	cout << ans << "\n";
	
	
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
3 1 1 1 1 2
1 5 3 3 7 4

output:

6

result:

wrong answer 1st lines differ - expected: '13', found: '6'