QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#34492 | #4248. Number Theory | yzhang | AC ✓ | 35ms | 4488kb | C++17 | 1.2kb | 2022-06-10 09:12:58 | 2022-06-10 09:13:00 |
Judging History
answer
//μ's forever
#include <bits/stdc++.h>
//#define getchar nc
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
register int x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x*f;
}
inline void write(register int x)
{
if(!x)putchar('0');if(x<0)x=-x,putchar('-');
static int sta[20];register int tot=0;
while(x)sta[tot++]=x%10,x/=10;
while(tot)putchar(sta[--tot]+48);
}
int p;
int vis[100005],cnt=0,c[100005];
int main()
{
p=read();
memset(vis,0x3f,sizeof(vis));
for(int i=0;i<p;++i){
int v=1ll*i*i%p;
vis[v]=min(vis[v],i);
}
for(int i=0;;++i){
for(int j=0;j<p;++j){
int val=(j-1ll*i*i%p+p)%p;
if(vis[val]<p&&c[j]==0){
++cnt;
c[j]=1;
}
}
if(cnt==p){
printf("%d\n",i);
return 0;
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 4028kb
input:
2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 4040kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 4000kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 2ms
memory: 4084kb
input:
7
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 35ms
memory: 4460kb
input:
99991
output:
20
result:
ok 1 number(s): "20"
Test #6:
score: 0
Accepted
time: 6ms
memory: 4056kb
input:
17041
output:
13
result:
ok 1 number(s): "13"
Test #7:
score: 0
Accepted
time: 5ms
memory: 4180kb
input:
25343
output:
12
result:
ok 1 number(s): "12"
Test #8:
score: 0
Accepted
time: 12ms
memory: 4228kb
input:
37309
output:
15
result:
ok 1 number(s): "15"
Test #9:
score: 0
Accepted
time: 14ms
memory: 4264kb
input:
58027
output:
15
result:
ok 1 number(s): "15"
Test #10:
score: 0
Accepted
time: 17ms
memory: 4304kb
input:
47843
output:
19
result:
ok 1 number(s): "19"
Test #11:
score: 0
Accepted
time: 10ms
memory: 4076kb
input:
33857
output:
14
result:
ok 1 number(s): "14"
Test #12:
score: 0
Accepted
time: 20ms
memory: 4280kb
input:
58921
output:
18
result:
ok 1 number(s): "18"
Test #13:
score: 0
Accepted
time: 21ms
memory: 4384kb
input:
90821
output:
14
result:
ok 1 number(s): "14"
Test #14:
score: 0
Accepted
time: 15ms
memory: 4292kb
input:
51749
output:
14
result:
ok 1 number(s): "14"
Test #15:
score: 0
Accepted
time: 3ms
memory: 4004kb
input:
16223
output:
14
result:
ok 1 number(s): "14"
Test #16:
score: 0
Accepted
time: 17ms
memory: 4292kb
input:
75503
output:
15
result:
ok 1 number(s): "15"
Test #17:
score: 0
Accepted
time: 10ms
memory: 4196kb
input:
29287
output:
15
result:
ok 1 number(s): "15"
Test #18:
score: 0
Accepted
time: 20ms
memory: 4364kb
input:
75653
output:
14
result:
ok 1 number(s): "14"
Test #19:
score: 0
Accepted
time: 20ms
memory: 4232kb
input:
61667
output:
17
result:
ok 1 number(s): "17"
Test #20:
score: 0
Accepted
time: 21ms
memory: 4272kb
input:
57773
output:
20
result:
ok 1 number(s): "20"
Test #21:
score: 0
Accepted
time: 26ms
memory: 4404kb
input:
82009
output:
17
result:
ok 1 number(s): "17"
Test #22:
score: 0
Accepted
time: 5ms
memory: 4096kb
input:
24251
output:
14
result:
ok 1 number(s): "14"
Test #23:
score: 0
Accepted
time: 27ms
memory: 4472kb
input:
99733
output:
17
result:
ok 1 number(s): "17"
Test #24:
score: 0
Accepted
time: 9ms
memory: 4180kb
input:
25849
output:
15
result:
ok 1 number(s): "15"
Test #25:
score: 0
Accepted
time: 20ms
memory: 4388kb
input:
72949
output:
18
result:
ok 1 number(s): "18"
Test #26:
score: 0
Accepted
time: 24ms
memory: 4416kb
input:
93523
output:
16
result:
ok 1 number(s): "16"
Test #27:
score: 0
Accepted
time: 22ms
memory: 4320kb
input:
75577
output:
16
result:
ok 1 number(s): "16"
Test #28:
score: 0
Accepted
time: 9ms
memory: 4240kb
input:
43201
output:
14
result:
ok 1 number(s): "14"
Test #29:
score: 0
Accepted
time: 30ms
memory: 4412kb
input:
99713
output:
20
result:
ok 1 number(s): "20"
Test #30:
score: 0
Accepted
time: 24ms
memory: 4400kb
input:
89563
output:
17
result:
ok 1 number(s): "17"
Test #31:
score: 0
Accepted
time: 6ms
memory: 4052kb
input:
15767
output:
14
result:
ok 1 number(s): "14"
Test #32:
score: 0
Accepted
time: 16ms
memory: 4288kb
input:
52379
output:
16
result:
ok 1 number(s): "16"
Test #33:
score: 0
Accepted
time: 12ms
memory: 4264kb
input:
28663
output:
21
result:
ok 1 number(s): "21"
Test #34:
score: 0
Accepted
time: 3ms
memory: 4060kb
input:
5087
output:
11
result:
ok 1 number(s): "11"
Test #35:
score: 0
Accepted
time: 5ms
memory: 4180kb
input:
24097
output:
14
result:
ok 1 number(s): "14"
Test #36:
score: 0
Accepted
time: 23ms
memory: 4444kb
input:
83047
output:
15
result:
ok 1 number(s): "15"
Test #37:
score: 0
Accepted
time: 20ms
memory: 4364kb
input:
70913
output:
15
result:
ok 1 number(s): "15"
Test #38:
score: 0
Accepted
time: 2ms
memory: 4148kb
input:
8069
output:
17
result:
ok 1 number(s): "17"
Test #39:
score: 0
Accepted
time: 24ms
memory: 4336kb
input:
72937
output:
18
result:
ok 1 number(s): "18"
Test #40:
score: 0
Accepted
time: 2ms
memory: 4112kb
input:
9391
output:
11
result:
ok 1 number(s): "11"
Test #41:
score: 0
Accepted
time: 15ms
memory: 4348kb
input:
63977
output:
15
result:
ok 1 number(s): "15"
Test #42:
score: 0
Accepted
time: 4ms
memory: 4016kb
input:
6779
output:
13
result:
ok 1 number(s): "13"
Test #43:
score: 0
Accepted
time: 3ms
memory: 4004kb
input:
3209
output:
11
result:
ok 1 number(s): "11"
Test #44:
score: 0
Accepted
time: 21ms
memory: 4300kb
input:
77081
output:
21
result:
ok 1 number(s): "21"
Test #45:
score: 0
Accepted
time: 32ms
memory: 4436kb
input:
98533
output:
18
result:
ok 1 number(s): "18"
Test #46:
score: 0
Accepted
time: 6ms
memory: 4192kb
input:
28859
output:
13
result:
ok 1 number(s): "13"
Test #47:
score: 0
Accepted
time: 5ms
memory: 4104kb
input:
12907
output:
13
result:
ok 1 number(s): "13"
Test #48:
score: 0
Accepted
time: 3ms
memory: 4228kb
input:
22349
output:
13
result:
ok 1 number(s): "13"
Test #49:
score: 0
Accepted
time: 5ms
memory: 4092kb
input:
11057
output:
13
result:
ok 1 number(s): "13"
Test #50:
score: 0
Accepted
time: 6ms
memory: 4140kb
input:
15809
output:
15
result:
ok 1 number(s): "15"
Test #51:
score: 0
Accepted
time: 6ms
memory: 4200kb
input:
14437
output:
14
result:
ok 1 number(s): "14"
Test #52:
score: 0
Accepted
time: 1ms
memory: 4084kb
input:
163
output:
5
result:
ok 1 number(s): "5"
Test #53:
score: 0
Accepted
time: 20ms
memory: 4488kb
input:
87313
output:
14
result:
ok 1 number(s): "14"
Test #54:
score: 0
Accepted
time: 0ms
memory: 4104kb
input:
761
output:
10
result:
ok 1 number(s): "10"
Test #55:
score: 0
Accepted
time: 21ms
memory: 4360kb
input:
86239
output:
16
result:
ok 1 number(s): "16"
Test #56:
score: 0
Accepted
time: 28ms
memory: 4428kb
input:
90163
output:
17
result:
ok 1 number(s): "17"
Test #57:
score: 0
Accepted
time: 10ms
memory: 4172kb
input:
30859
output:
14
result:
ok 1 number(s): "14"
Test #58:
score: 0
Accepted
time: 14ms
memory: 4172kb
input:
47807
output:
15
result:
ok 1 number(s): "15"
Test #59:
score: 0
Accepted
time: 4ms
memory: 4104kb
input:
7547
output:
11
result:
ok 1 number(s): "11"
Test #60:
score: 0
Accepted
time: 5ms
memory: 4200kb
input:
13327
output:
12
result:
ok 1 number(s): "12"
Test #61:
score: 0
Accepted
time: 11ms
memory: 4216kb
input:
33577
output:
15
result:
ok 1 number(s): "15"
Test #62:
score: 0
Accepted
time: 0ms
memory: 4088kb
input:
127
output:
6
result:
ok 1 number(s): "6"
Test #63:
score: 0
Accepted
time: 12ms
memory: 4224kb
input:
38711
output:
14
result:
ok 1 number(s): "14"
Test #64:
score: 0
Accepted
time: 4ms
memory: 4132kb
input:
8377
output:
11
result:
ok 1 number(s): "11"
Test #65:
score: 0
Accepted
time: 9ms
memory: 4212kb
input:
36607
output:
15
result:
ok 1 number(s): "15"
Test #66:
score: 0
Accepted
time: 25ms
memory: 4412kb
input:
83299
output:
17
result:
ok 1 number(s): "17"
Test #67:
score: 0
Accepted
time: 6ms
memory: 4176kb
input:
14303
output:
16
result:
ok 1 number(s): "16"
Test #68:
score: 0
Accepted
time: 10ms
memory: 4196kb
input:
32003
output:
14
result:
ok 1 number(s): "14"