QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470550 | #6399. Classic: Classical Problem | UESTC_xxx# | WA | 0ms | 8044kb | C++14 | 1.4kb | 2024-07-10 15:02:42 | 2024-07-10 15:02:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL maxn = 1e9+10,N=3*1e5+120,g=239,mod=1e9 + 7,cmod=998244353,INF=1e16;
int n,m,k,t,p;
LL qk(LL k,LL x,LL p)
{
if(x==0) return 0;
LL re=1;
while(k)
{
if(k&1) re=(re*x)%p;
x=(x*x)%p;
k>>=1;
}
return re;
}
int a[N],ans[N],cnt=0,q[2][N],qc[2];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&n,&p);
qc[0]=qc[1]=0;
int mid;
for(int i=0;i<p;i++) a[i]=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&mid);
a[mid]=1;
}
if(n==p)
{
printf("%d %d\n",p-1,p);
for(int i=1;i<p;i++)
{
if(i==1)
printf("%d",i);
else
printf(" %d",i);
if(i==p-1)
printf("\n");
}
}
else if(a[0]==0)
{
printf("1 1\n0\n");
}else
{
for(int i=0;i<p;i++)
q[0][++qc[0]]=i;
int ff=0;
for(int i=1;i<p;i++)
{
cnt=0;
while(qc[(i+1)&1]!=0)
{
int x=q[(i+1)&1][qc[(i+1)&1]];
--qc[(i+1)&1];
ans[++cnt]=x;
if(x!=0&&a[(1LL*i*x)%p]==1)
q[i&1][++qc[i&1]]=x;
}
if(qc[i&1]==0)
{
printf("%d %d\n",cnt,i);
for(int i=1;i<=cnt;i++)
ans[i]=qk(p-2,ans[i],p);
sort(ans+1,ans+cnt+1);
for(int j=1;j<=cnt;j++)
{
printf("%d ",ans[j]);
}
printf("\n");
break;
}
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8044kb
input:
3 2 3 0 2 3 5 2 3 4 3 5 0 2 3
output:
1 2 2
result:
wrong answer 3rd lines differ - expected: '1 1', found: ''