QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#658264#5301. Modulo Ruins the LegendyillinWA 0ms3688kbC++202.2kb2024-10-19 16:30:132024-10-19 16:30:22

Judging History

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

  • [2024-10-19 16:30:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-10-19 16:30:13]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define PII pair<int,int>
#define ull unsigned long long
//#define lson (o << 1)
//#define rson (o << 1 | 1)
#define mt ((l+r)/2)
#define lowbit(x) x & -x
#define endl '\n'
using namespace std;
using ll = long long;
inline int read(){int k=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}//getchar_unlocked()
while(c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return k*f;}
template<typename T>T qpow(T a, ll n){T ans = 1; while (n){if (n & 1)ans = ans * a; n >>= 1;a = a * a;}return ans;}
int exgcd(int a,int b,int &x,int &y){if(b==0){x=1;y=0;return a;}int d=exgcd(b,a%b,y,x);y-=(a/b)*x;return d;}
template<typename T> inline void print(T x) { if (x > 9)  print(x / 10); putchar(x % 10 + '0'); }
template<typename T> inline void Pr(T x, char c = '\n') { if (x < 0) putchar('-'), x = -x; print(x); putchar(c); }
inline void write(int x){if(x<0)putchar('-'),x=-x;if (x > 9) write(x / 10);putchar(x % 10 + '0');}
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f3f3f3f3f;
//const int p = 1e9 + 7;
const int N=3e5+10;
//int a[maxn],b[maxn];
//int a[N],b[N];
//const int N = 2e5 + 10;
//string s[705];
int a[N],b[N];
void solve() 
{
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
    	int num;
    	cin>>num;
    	sum+=num;
	}
	sum%=m;
	if(sum==0)
	{
		cout<<0<<endl;
		cout<<0<<' '<<0<<endl;
		return; 
	}
	int a=n*(n+1)/2;
	int b=n;
	int x,y;//x--d,y--s
	exgcd(a,b,x,y);
	int aa=__gcd(a,b);
	x=(x+m)%m;y=(y+m)%m;
	int bb=m;
	int q,t;
	int tmp=exgcd(aa,bb,q,t);
	y=(q*y+m)%m;
	x=(q*x+m)%m;
	int qq=(m-sum+tmp-1)/tmp;
	qq=(m-sum)/tmp;
	int k=((qq*tmp)+sum+m)%m;
	cout<<k<<endl;
	cout<<(y*qq+m)%m<<' '<<(x*qq+m)%m<<endl;
	/*
	for(int i=0;i<m;i++)
	{
		int tmp=i+m-sum;
		if(tmp%qq==0)
		{
			//cout<<"tmp:"<<tmp<<endl;
			int s=tmp/qq;
			cout<<i<<endl;
			//cout<<y*s<<' '<<x*s<<endl;
			//cout<<y<<' '<<x<<endl;
			cout<<(y*s+m)%m<<' '<<(x*s+m)%m<<endl;
			return;
		}
	}*/
	//
}
signed main()
{
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int _;
	_=1;
	//cin >> _;
    while(_--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 24
1 1 4 5 1 4

output:

22
18 2

result:

wrong answer Participant answer greater than judge