QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642839#5301. Modulo Ruins the Legenducup-team3474RE 0ms0kbC++20737b2024-10-15 16:33:242024-10-15 16:33:24

Judging History

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

  • [2024-10-15 16:33:24]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-15 16:33:24]
  • 提交

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){
    if(b==0){
        x=1,y=0;
        return a;
    }
    ll d=exgcd(b,a%b,y,x);
    y-=(a/b)*x;
}

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;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

6 24
1 1 4 5 1 4

output:

1

result: