QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#642849#5301. Modulo Ruins the Legenducup-team3474WA 1ms5864kbC++20799b2024-10-15 16:35:202024-10-15 16:35:20

Judging History

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

  • [2024-10-15 16:35:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5864kb
  • [2024-10-15 16:35:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
bool tf[N];

ll exgcd(ll a,ll b,ll &x,ll &y){
    // cout<<a<<" "<<b<<" "<<x<<" "<<y<<endl;
    if(b==0){
        x=1,y=0;
        return a;
    }
    ll d=exgcd(b,a%b,y,x);
    y-=(a/b)*x;
    return d;
}

int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    ll C=0;
    for(int i=1;i<=n;i++) C=(C+a[i])%m;
    ll a=n,b=1ll*n*(n+1)/2;
    ll gg=__gcd(a,b);
    // cout<<gg<<endl;
    gg=__gcd(gg,m);
    ll ans=C%gg;
    cout<<ans<<endl;
    ll nw=m+ans;
    ll x,y;
    exgcd(a,b,x,y);
    x*=nw,y*=nw;
    x%=m,y%=m;
    if(x<0) x+=m;
    if(y<0) y+=m;
    cout<<x<<' '<<y<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5864kb

input:

6 24
1 1 4 5 1 4

output:

1
21 1

result:

wrong answer Result not equal to solution.