QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#471225 | #6399. Classic: Classical Problem | UESTC_DECAYALI | WA | 1ms | 3980kb | C++17 | 1.1kb | 2024-07-10 19:41:41 | 2024-07-10 19:41:41 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005;
int t,n,p,x,a[N],ans[N];
inline int quick_pow(int x,int mod,int p,int mul=1)
{
for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
int main()
{
//freopen("F.in","r",stdin);
for (scanf("%d",&t);t;--t)
{
RI i,c; for (scanf("%d%d",&n,&p),i=0;i<p;++i) a[i]=0;
for (i=1;i<=n;++i) scanf("%d",&x),a[x]=1;
if (!a[0]) { puts("1 1\n0"); continue; } else ans[0]=1;
if (p-n<=(int)sqrt(p))
{
vector <int> vec;
for (i=0;i<p;++i) if (!a[i]) vec.push_back(i);
for (c=0;c<p;++c)
{
int mex=p;
for (auto x:vec) mex=min(mex,(int)(1LL*c*x%p));
ans[c]=mex;
}
} else
{
for (c=0;c<p;++c)
{
int mex=1,inv=quick_pow(c,p,p-2);
while (a[1LL*mex*inv%p]) ++mex;
ans[c]=mex;
}
}
int mx=0; vector <int> num;
for (i=0;i<p;++i) mx=max(mx,ans[i]);
for (i=0;i<p;++i) if (ans[i]==mx) num.push_back(i);
printf("%d %d\n",num.size(),mx);
for (auto x:num) printf("%d ",x); putchar('\n');
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3852kb
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: -100
Wrong Answer
time: 1ms
memory: 3980kb
input:
3 1 2 0 1 2 1 2 2 1 0
output:
1 1 1 1 1 0 2 2 0 1
result:
wrong answer 1st lines differ - expected: '2 1', found: '1 1'