QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100801#5377. $N$ 门问题lenlenCompile Error//C++141.8kb2023-04-28 10:22:052023-04-28 10:22:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 10:22:07]
  • 评测
  • [2023-04-28 10:22:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+7232;
int n;
struct EXCRT{
    int a[N],p[N],x,y;
    int mul(int a,int b,int p)
    {
        int sum=0;b=(b%p+p)%p;
        while(b)
        {
            if(b&1) (sum+=a)%=p;
            (a<<=1)%=p;b>>=1;
        }
        return sum;
    }
    void init(){for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&p[i]);}
    int exgcd(int a,int b,int &x,int &y)
    {
        if(!b) {x=1,y=0;return a;}
        int gcd=exgcd(b,a%b,x,y);
        int z=x;x=y;y=z-y*(a/b);
        return gcd;
    }
    bool merge(int k)
    {
        int d=exgcd(p[k],p[k+1],x,y);
        // cout<<d<<"\n"<<a[k]<<" "<<p[k]<<" "<<a[k+1]<<p[k+1];
        if((a[k+1]-a[k])%d) return true;
        int tmp=exgcd(p[k]/d,p[k+1]/d,x,y);
        p[k+1]=p[k]/exgcd(p[k],p[k+1],x,y)*p[k+1];
        a[k+1]=a[k]+mul(mul((a[k+1]-a[k])/d,x,p[k+1]),p[k],p[k+1]);
        return false;
    }
    int ask()
    {
        for(int i=1;i<n;i++) 
        {
            if(merge(i)) return -1;
            // cout<<a[i+1]<<" "<<p[i+1]<<"\n";cout<<"\n";
        }
        return (a[n]%p[n]+p[n])%p[n];  
    }
}CRT;
int s[N];
double p[N];
bitset<N> vis;
// void check()
// {
//     for(int i=1;i<=n;i++) p[i]=1/n;
//     for()
// }
// void dfs(int x)
// {
//     if(x==n+1) {check();return ;}
//     for(int i=1;i<=n;i++)
//     {
//         if(vis[i]) continue;
//         vis[i]=1;s[x]=i;dfs(x+1);vis[i]=0;
//     } 
// }
signed main()
{
    scanf("%lld",&n);
    CRT.init();
    n=CRT.ask();
    else if(n>10) printf("0.000000\n");
    else if(n==1||n==-1) printf("error\n");
    else if(n==2) printf("0.500000\n");
    else if(n==3) printf("0.666667\n");
    else if(n==4) printf("0.625000\n");
}

Details

answer.code: In function ‘int main()’:
answer.code:68:5: error: ‘else’ without a previous ‘if’
   68 |     else if(n>10) printf("0.000000\n");
      |     ^~~~
answer.code:65:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
answer.code: In member function ‘void EXCRT::init()’:
answer.code:18:44: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     void init(){for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&p[i]);}
      |                                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~