QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#654451 | #1835. Fancy Formulas | ucup-team3474 | Compile Error | / | / | C++23 | 1.3kb | 2024-10-18 21:35:29 | 2024-10-18 21:35:31 |
Judging History
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,p;
ll a[N],b[N];
char s[N];
ll cnt[N];
int num[N];
void print(ll x){
cout<<(x%p+p)%p<<" ";
}
ll ksm(ll x,ll p,ll mod){
ll sum=1,item=x;
while(p){
if(p&1) sum=sum*item%mod;
p>>=1;
item=item*item%mod;
}
return sum;
}
void __(){
ll a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if((a+b)%p!=(c+d)%p){
puts("-1");
return;
}
ll res=(a+b)%p;
int ans=100;
ll x=a;
if(a==c&&b==d){
puts("0");
return;
}
// cout<<64*a-c<<endl;
for(int i=1;i<=40;i++){
ll T=(1ll<<i)%p;
ll R=(T*a-c)%p;
R=(R+p)%p;
// cout<<ksm(a+b,p-2,p)<<endl;
ll K=R*ksm(a+b,p-2,p)%p;
// if(K>0) K-=p;
if(K<T){
// cout<<K<<endl;
ans=min(ans,i);
break;
}
}
printf("%d\n",ans);
}
int main(){
int _=1;
cin>>p;
cin>>_;
while(_--){
__();
}
}
詳細信息
answer.code:14:1: error: extended character is not valid in an identifier 14 | cout<<(x%p+p)%p<<" "; | ^ answer.code:14:3: error: extended character is not valid in an identifier 14 | cout<<(x%p+p)%p<<" "; | ^ answer.code:20:1: error: extended character is not valid in an identifier 20 | ll sum=1,item=x; | ^ answer.code:20:3: error: extended character is not valid in an identifier 20 | ll sum=1,item=x; | ^ answer.code:21:1: error: extended character is not valid in an identifier 21 | while(p){ | ^ answer.code:21:3: error: extended character is not valid in an identifier 21 | while(p){ | ^ answer.code:22:1: error: extended character is not valid in an identifier 22 | if(p&1) sum=sum*item%mod; | ^ answer.code:22:3: error: extended character is not valid in an identifier 22 | if(p&1) sum=sum*item%mod; | ^ answer.code:22:5: error: extended character is not valid in an identifier 22 | if(p&1) sum=sum*item%mod; | ^ answer.code:22:7: error: extended character is not valid in an identifier 22 | if(p&1) sum=sum*item%mod; | ^ answer.code:23:1: error: extended character is not valid in an identifier 23 | p>>=1; | ^ answer.code:23:3: error: extended character is not valid in an identifier 23 | p>>=1; | ^ answer.code:23:5: error: extended character is not valid in an identifier 23 | p>>=1; | ^ answer.code:23:7: error: extended character is not valid in an identifier 23 | p>>=1; | ^ answer.code:24:1: error: extended character is not valid in an identifier 24 | item=item*item%mod; | ^ answer.code:24:3: error: extended character is not valid in an identifier 24 | item=item*item%mod; | ^ answer.code:24:5: error: extended character is not valid in an identifier 24 | item=item*item%mod; | ^ answer.code:24:7: error: extended character is not valid in an identifier 24 | item=item*item%mod; | ^ answer.code:25:1: error: extended character is not valid in an identifier 25 | } | ^ answer.code:25:3: error: extended character is not valid in an identifier 25 | } | ^ answer.code:26:1: error: extended character is not valid in an identifier 26 | return sum; | ^ answer.code:26:3: error: extended character is not valid in an identifier 26 | return sum; | ^ answer.code:30:1: error: extended character is not valid in an identifier 30 | ll a,b,c,d; | ^ answer.code:30:3: error: extended character is not valid in an identifier 30 | ll a,b,c,d; | ^ answer.code:31:1: error: extended character is not valid in an identifier 31 | scanf("%lld%lld%lld%lld",&a,&b,&c,&d); | ^ answer.code:31:3: error: extended character is not valid in an identifier 31 | scanf("%lld%lld%lld%lld",&a,&b,&c,&d); | ^ answer.code:32:1: error: extended character is not valid in an identifier 32 | if((a+b)%p!=(c+d)%p){ | ^ answer.code:32:3: error: extended character is not valid in an identifier 32 | if((a+b)%p!=(c+d)%p){ | ^ answer.code:33:1: error: extended character is not valid in an identifier 33 | puts("-1"); | ^ answer.code:33:3: error: extended character is not valid in an identifier 33 | puts("-1"); | ^ answer.code:33:5: error: extended character is not valid in an identifier 33 | puts("-1"); | ^ answer.code:33:7: error: extended character is not valid in an identifier 33 | puts("-1"); | ^ answer.code:34:1: error: extended character is not valid in an identifier 34 | return; | ^ answer.code:34:3: error: extended character is not valid in an identifier 34 | return; | ^ answer.code:34:5: error: extended character is not valid in an identifier 34 | return; | ^ answer.code:34:7: error: extended character is not valid in an identifier 34 | return; | ^ answer.code:35:1: error: extended character is not valid in an identifier 35 | } | ^ answer.code:35:3: error: extended character is not valid in an identifier 35 | } | ^ answer.code:36:1: error: extended character is not valid in an identifier 36 | ll res=(a+b)%p; | ^ answer.code:36:3: error: extended character is not valid in an identifier 36 | ll res=(a+b)%p; | ^ answer.code:37:1: error: extended character is not valid in an identifier 37 | int ans=100; | ^ answer.code:37:3: error: extended character is not valid in an identifier 37 | int ans=100; | ^ answer.code:38:1: error: extended character is not valid in an identifier 38 | ll x=a; ...