QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#107064#5301. Modulo Ruins the LegendshiyihangxsCompile Error//C++141.5kb2023-05-20 10:25:262023-05-20 10:25:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-20 10:25:54]
  • 评测
  • [2023-05-20 10:25:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define mpr make_pair
//mt19937_64 ra(time(0) ^ (*new char));
//ios::sync_with_stdio(false);
//cin.tie(0); cout.tie(0);
const ll SIZE = 200005;
const ll mod = 998244353;
ll n, m;
ll a[SIZE];
ll sum;
 
inline ll rd(){
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = (x<<1) + (x<<3) + (ch^48);
		ch = getchar();
	}
	return x*f;
}
 
ll power(ll x, ll y){
	ll jl = 1;
	while(y){
		if(y & 1) jl = (jl * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return jl;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y){
	if(!b){
		x = 1, y = 0;
		return a;
	}	
	ll d = exgcd(b, a%b, x, y);
	ll z = x; x = y, y = z - y*(a/b);
	return d;
}
 
int main(){
	n = rd(), m = rd();
	for(ll i = 1; i <= n; i++) a[i] = rd(), sum = (sum + a[i]) % m;
	ll a = n, b = (n+1)*n/2, x, y;
	ll gg = exgcd(a, b, x, y), ggg = __gcd(gg, m);
	ll c = (m-sum)%m;
	ll ans = (c/ggg+(c%ggg==0?0:1)) * ggg;
	c = ans;
	ll xx, yy;
	ll gg1 = exgcd(m, gg, xx, yy);
	xx = xx*(c/gg1);
	c = c+(-xx)*m;
	if(m == 998244353) cout << cc << endl;
	ans = (sum+ans) % m;
	x = x*(c/gg), y = y*(c/gg);
//	cout << x << " " << y << endl;
	ll kkx = b/gg, kky = a/gg;
	ll aa = ceil(-((double)x/(double)kkx)), bb = floor((double)y/(double)kky);
	printf("%lld\n%lld %lld", ans, ((x+aa*kkx)%m+m)%m, ((y-aa*kky)%m+m)%m);
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:63:36: error: ‘cc’ was not declared in this scope; did you mean ‘c’?
   63 |         if(m == 998244353) cout << cc << endl;
      |                                    ^~
      |                                    c