QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470515 | #6399. Classic: Classical Problem | UESTC_xxx# | WA | 1ms | 6176kb | C++14 | 1.3kb | 2024-07-10 14:44:06 | 2024-07-10 14:44:07 |
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;
LL 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;
}
LL a[N],ans[N],cnt=0;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&n,&p);
queue<int> q[2],qmid;
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].push(i);
int ff=0;
for(int i=1;i<p;i++)
{
cnt=0;
while(!q[(i+1)%2].empty())
{
int x=q[(i+1)%2].front();
q[(i+1)%2].pop();
ans[++cnt]=qk(p-2,x,p);
if(x!=0&&a[i*x]==1)
q[i%2].push(x);
}
if(q[i%2].empty())
{
printf("%d %d\n",cnt,i);
sort(ans+1,ans+cnt+1);
for(int j=1;j<=cnt;j++)
{
printf("%d ",ans[j]);
}
printf("\n");
break;
}
}
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5844kb
input:
3 2 3 0 2 3 5 2 3 4 3 5 0 2 3
output:
1 2 2 1 1 0 2 2 2 3
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 6176kb
input:
3 1 2 0 1 2 1 2 2 1 0
output:
2 1 0 1 1 1 0 1 2 1
result:
ok 6 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 5856kb
input:
7 1 3 0 1 3 1 2 3 1 0 1 3 2 2 3 2 0 2 3 1 2 3 3 0 1 2
output:
3 1 0 1 2 1 1 0 1 2 1 1 1 0 1 2 2 1 1 0 2 3 1 2
result:
ok 14 lines
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 5848kb
input:
31 1 5 0 1 5 1 2 5 1 0 1 5 2 2 5 0 2 2 5 2 1 3 5 1 0 2 1 5 3 2 5 0 3 2 5 1 3 3 5 0 1 3 2 5 3 2 3 5 0 2 3 3 5 2 1 3 4 5 2 0 1 3 1 5 4 2 5 4 0 2 5 1 4 3 5 1 4 0 2 5 2 4 3 5 2 4 0 3 5 4 2 1 4 5 1 0 4 2 2 5 4 3 3 5 0 4 3 3 5 3 1 4 4 5 1 4 3 0 3 5 4 3 2 4 5 2 4 0 3 4 5 2 1 4 3 5 5 1 3 0 2 4
output:
5 1 0 1 2 3 4 1 1 0 1 2 1 1 1 0 1 2 3 1 1 0 1 3 1 1 1 0 1 2 2 1 1 0 2 2 1 2 1 1 0 2 2 2 3 1 1 0 1 4 1 1 1 0 1 2 4 1 1 0 2 2 1 4 1 1 0 1 3 3 1 1 0 2 3 1 3 1 1 0 2 2 2 4 1 1 0 3 2 1 2 4 1 1 0 1 3 3 1 1 0 4 5 1 2 3 4
result:
wrong answer 21st lines differ - expected: '1 3', found: '2 2'