QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#808961 | #4248. Number Theory | ucup-team2172# | AC ✓ | 8ms | 5668kb | C++23 | 929b | 2024-12-11 09:58:55 | 2024-12-11 09:59:01 |
Judging History
answer
#pragma GCC optimize("Ofast", "O3", "inline", "unroll-loops")
#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
int ch = 0, f = 0; x = 0;
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
if(f) x = -x;
}
int p;
unordered_map<int, int> mp;
int main(){
read(p);
for(int i = 0; i < p; i++){
int val = 1ll * i * i % p;
if(!mp.count(val)) mp[val] = 1;
}
int ans = 0;
for(int i = 0; i < p; i++){
int j = 0;
for(j = 0; ; j++){
int val = 1ll * j * j % p;
if(mp.count((i + p - val) % p)) break;
}
ans = max(ans, j);
}
printf("%d", ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
5
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
7
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 8ms
memory: 5644kb
input:
99991
output:
20
result:
ok 1 number(s): "20"
Test #6:
score: 0
Accepted
time: 2ms
memory: 4060kb
input:
17041
output:
13
result:
ok 1 number(s): "13"
Test #7:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
25343
output:
12
result:
ok 1 number(s): "12"
Test #8:
score: 0
Accepted
time: 3ms
memory: 4540kb
input:
37309
output:
15
result:
ok 1 number(s): "15"
Test #9:
score: 0
Accepted
time: 4ms
memory: 4884kb
input:
58027
output:
15
result:
ok 1 number(s): "15"
Test #10:
score: 0
Accepted
time: 3ms
memory: 4728kb
input:
47843
output:
19
result:
ok 1 number(s): "19"
Test #11:
score: 0
Accepted
time: 3ms
memory: 4248kb
input:
33857
output:
14
result:
ok 1 number(s): "14"
Test #12:
score: 0
Accepted
time: 5ms
memory: 4704kb
input:
58921
output:
18
result:
ok 1 number(s): "18"
Test #13:
score: 0
Accepted
time: 7ms
memory: 5572kb
input:
90821
output:
14
result:
ok 1 number(s): "14"
Test #14:
score: 0
Accepted
time: 4ms
memory: 4520kb
input:
51749
output:
14
result:
ok 1 number(s): "14"
Test #15:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
16223
output:
14
result:
ok 1 number(s): "14"
Test #16:
score: 0
Accepted
time: 6ms
memory: 4940kb
input:
75503
output:
15
result:
ok 1 number(s): "15"
Test #17:
score: 0
Accepted
time: 2ms
memory: 4176kb
input:
29287
output:
15
result:
ok 1 number(s): "15"
Test #18:
score: 0
Accepted
time: 3ms
memory: 4900kb
input:
75653
output:
14
result:
ok 1 number(s): "14"
Test #19:
score: 0
Accepted
time: 5ms
memory: 5016kb
input:
61667
output:
17
result:
ok 1 number(s): "17"
Test #20:
score: 0
Accepted
time: 4ms
memory: 4668kb
input:
57773
output:
20
result:
ok 1 number(s): "20"
Test #21:
score: 0
Accepted
time: 7ms
memory: 4924kb
input:
82009
output:
17
result:
ok 1 number(s): "17"
Test #22:
score: 0
Accepted
time: 2ms
memory: 4384kb
input:
24251
output:
14
result:
ok 1 number(s): "14"
Test #23:
score: 0
Accepted
time: 4ms
memory: 5496kb
input:
99733
output:
17
result:
ok 1 number(s): "17"
Test #24:
score: 0
Accepted
time: 2ms
memory: 4112kb
input:
25849
output:
15
result:
ok 1 number(s): "15"
Test #25:
score: 0
Accepted
time: 6ms
memory: 4928kb
input:
72949
output:
18
result:
ok 1 number(s): "18"
Test #26:
score: 0
Accepted
time: 7ms
memory: 5608kb
input:
93523
output:
16
result:
ok 1 number(s): "16"
Test #27:
score: 0
Accepted
time: 6ms
memory: 4896kb
input:
75577
output:
16
result:
ok 1 number(s): "16"
Test #28:
score: 0
Accepted
time: 3ms
memory: 4396kb
input:
43201
output:
14
result:
ok 1 number(s): "14"
Test #29:
score: 0
Accepted
time: 8ms
memory: 5668kb
input:
99713
output:
20
result:
ok 1 number(s): "20"
Test #30:
score: 0
Accepted
time: 3ms
memory: 5624kb
input:
89563
output:
17
result:
ok 1 number(s): "17"
Test #31:
score: 0
Accepted
time: 2ms
memory: 4040kb
input:
15767
output:
14
result:
ok 1 number(s): "14"
Test #32:
score: 0
Accepted
time: 0ms
memory: 4536kb
input:
52379
output:
16
result:
ok 1 number(s): "16"
Test #33:
score: 0
Accepted
time: 2ms
memory: 4092kb
input:
28663
output:
21
result:
ok 1 number(s): "21"
Test #34:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5087
output:
11
result:
ok 1 number(s): "11"
Test #35:
score: 0
Accepted
time: 0ms
memory: 4064kb
input:
24097
output:
14
result:
ok 1 number(s): "14"
Test #36:
score: 0
Accepted
time: 7ms
memory: 5032kb
input:
83047
output:
15
result:
ok 1 number(s): "15"
Test #37:
score: 0
Accepted
time: 6ms
memory: 4892kb
input:
70913
output:
15
result:
ok 1 number(s): "15"
Test #38:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
8069
output:
17
result:
ok 1 number(s): "17"
Test #39:
score: 0
Accepted
time: 3ms
memory: 4848kb
input:
72937
output:
18
result:
ok 1 number(s): "18"
Test #40:
score: 0
Accepted
time: 1ms
memory: 4148kb
input:
9391
output:
11
result:
ok 1 number(s): "11"
Test #41:
score: 0
Accepted
time: 5ms
memory: 4724kb
input:
63977
output:
15
result:
ok 1 number(s): "15"
Test #42:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
6779
output:
13
result:
ok 1 number(s): "13"
Test #43:
score: 0
Accepted
time: 1ms
memory: 3920kb
input:
3209
output:
11
result:
ok 1 number(s): "11"
Test #44:
score: 0
Accepted
time: 7ms
memory: 5168kb
input:
77081
output:
21
result:
ok 1 number(s): "21"
Test #45:
score: 0
Accepted
time: 4ms
memory: 5576kb
input:
98533
output:
18
result:
ok 1 number(s): "18"
Test #46:
score: 0
Accepted
time: 2ms
memory: 4240kb
input:
28859
output:
13
result:
ok 1 number(s): "13"
Test #47:
score: 0
Accepted
time: 1ms
memory: 3948kb
input:
12907
output:
13
result:
ok 1 number(s): "13"
Test #48:
score: 0
Accepted
time: 2ms
memory: 4128kb
input:
22349
output:
13
result:
ok 1 number(s): "13"
Test #49:
score: 0
Accepted
time: 1ms
memory: 4012kb
input:
11057
output:
13
result:
ok 1 number(s): "13"
Test #50:
score: 0
Accepted
time: 2ms
memory: 4092kb
input:
15809
output:
15
result:
ok 1 number(s): "15"
Test #51:
score: 0
Accepted
time: 1ms
memory: 4292kb
input:
14437
output:
14
result:
ok 1 number(s): "14"
Test #52:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
163
output:
5
result:
ok 1 number(s): "5"
Test #53:
score: 0
Accepted
time: 0ms
memory: 5408kb
input:
87313
output:
14
result:
ok 1 number(s): "14"
Test #54:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
761
output:
10
result:
ok 1 number(s): "10"
Test #55:
score: 0
Accepted
time: 6ms
memory: 5628kb
input:
86239
output:
16
result:
ok 1 number(s): "16"
Test #56:
score: 0
Accepted
time: 7ms
memory: 5560kb
input:
90163
output:
17
result:
ok 1 number(s): "17"
Test #57:
score: 0
Accepted
time: 2ms
memory: 4264kb
input:
30859
output:
14
result:
ok 1 number(s): "14"
Test #58:
score: 0
Accepted
time: 3ms
memory: 4472kb
input:
47807
output:
15
result:
ok 1 number(s): "15"
Test #59:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
7547
output:
11
result:
ok 1 number(s): "11"
Test #60:
score: 0
Accepted
time: 1ms
memory: 4272kb
input:
13327
output:
12
result:
ok 1 number(s): "12"
Test #61:
score: 0
Accepted
time: 3ms
memory: 4312kb
input:
33577
output:
15
result:
ok 1 number(s): "15"
Test #62:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
127
output:
6
result:
ok 1 number(s): "6"
Test #63:
score: 0
Accepted
time: 0ms
memory: 4316kb
input:
38711
output:
14
result:
ok 1 number(s): "14"
Test #64:
score: 0
Accepted
time: 1ms
memory: 3960kb
input:
8377
output:
11
result:
ok 1 number(s): "11"
Test #65:
score: 0
Accepted
time: 3ms
memory: 4536kb
input:
36607
output:
15
result:
ok 1 number(s): "15"
Test #66:
score: 0
Accepted
time: 7ms
memory: 5288kb
input:
83299
output:
17
result:
ok 1 number(s): "17"
Test #67:
score: 0
Accepted
time: 1ms
memory: 4288kb
input:
14303
output:
16
result:
ok 1 number(s): "16"
Test #68:
score: 0
Accepted
time: 3ms
memory: 4492kb
input:
32003
output:
14
result:
ok 1 number(s): "14"