#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n, k;
long long ansT, ans = 10000000000LL;
int a[100000], b[100000], x2[100000], y2[100000];
int main(){std::ios::sync_with_stdio(false);
cin>>n>>k;
for(long long i=0;i<k;i++)
{
cin>>a[i]>>b[i]>>x2[i]>>y2[i];
a[i]--,b[i]--,y2[i]--,x2[i]--;
}
for(int j = 1; j < n; ++j)
if(n % j == 0) {
ansT = 0;
for(int i = 0; i < k; ++i)
if((a[i]/j + b[i]/j) % 2 == 0)
++ansT;
ansT = ansT * 2 - k;
if(ansT + (long long)n * n / j / j / 2 * j * j < ans)
ans = ansT + (long long)n * n / j / j / 2 * j * j;
ansT = -ansT;
if(ansT + ((long long)n * n / j / j + 1) / 2 * j * j < ans)
ans = ansT + ((long long)n * n / j / j + 1) / 2 * j * j;
}
//cout<<ansT+K-ansS<<" "<<ansS+k-ansT<<endl;
cout<<ans<<endl;
}
/*
* *
* * * *
* * * *
* * * *
* * * *
* * *
* *
* *
* *
* *
* *
* *
* *
* *
*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
412 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
460 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1404 KB |
Output is correct |
2 |
Correct |
11 ms |
1404 KB |
Output is correct |
3 |
Correct |
21 ms |
1404 KB |
Output is correct |
4 |
Correct |
23 ms |
1404 KB |
Output is correct |
5 |
Correct |
30 ms |
1404 KB |
Output is correct |
6 |
Correct |
23 ms |
1404 KB |
Output is correct |
7 |
Correct |
6 ms |
1404 KB |
Output is correct |
8 |
Correct |
17 ms |
1404 KB |
Output is correct |
9 |
Correct |
42 ms |
2004 KB |
Output is correct |
10 |
Correct |
25 ms |
2004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2004 KB |
Output is correct |
2 |
Correct |
2 ms |
2004 KB |
Output is correct |
3 |
Correct |
2 ms |
2004 KB |
Output is correct |
4 |
Correct |
2 ms |
2004 KB |
Output is correct |
5 |
Correct |
2 ms |
2004 KB |
Output is correct |
6 |
Correct |
2 ms |
2004 KB |
Output is correct |
7 |
Correct |
2 ms |
2004 KB |
Output is correct |
8 |
Correct |
2 ms |
2004 KB |
Output is correct |
9 |
Correct |
2 ms |
2004 KB |
Output is correct |
10 |
Correct |
2 ms |
2004 KB |
Output is correct |
11 |
Correct |
3 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
2004 KB |
Output is correct |
13 |
Correct |
3 ms |
2004 KB |
Output is correct |
14 |
Correct |
4 ms |
2004 KB |
Output is correct |
15 |
Correct |
3 ms |
2004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2004 KB |
Output is correct |
2 |
Correct |
2 ms |
2004 KB |
Output is correct |
3 |
Correct |
2 ms |
2004 KB |
Output is correct |
4 |
Correct |
2 ms |
2004 KB |
Output is correct |
5 |
Correct |
2 ms |
2004 KB |
Output is correct |
6 |
Correct |
2 ms |
2004 KB |
Output is correct |
7 |
Correct |
2 ms |
2004 KB |
Output is correct |
8 |
Correct |
2 ms |
2004 KB |
Output is correct |
9 |
Correct |
2 ms |
2004 KB |
Output is correct |
10 |
Correct |
2 ms |
2004 KB |
Output is correct |
11 |
Correct |
3 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
2004 KB |
Output is correct |
13 |
Correct |
3 ms |
2004 KB |
Output is correct |
14 |
Correct |
4 ms |
2004 KB |
Output is correct |
15 |
Correct |
3 ms |
2004 KB |
Output is correct |
16 |
Correct |
14 ms |
2004 KB |
Output is correct |
17 |
Correct |
62 ms |
2004 KB |
Output is correct |
18 |
Correct |
45 ms |
2196 KB |
Output is correct |
19 |
Correct |
54 ms |
2196 KB |
Output is correct |
20 |
Correct |
67 ms |
2196 KB |
Output is correct |
21 |
Correct |
71 ms |
2196 KB |
Output is correct |
22 |
Correct |
2 ms |
2196 KB |
Output is correct |
23 |
Correct |
22 ms |
2196 KB |
Output is correct |
24 |
Correct |
41 ms |
2196 KB |
Output is correct |
25 |
Correct |
9 ms |
2196 KB |
Output is correct |
26 |
Correct |
25 ms |
2196 KB |
Output is correct |
27 |
Correct |
30 ms |
2196 KB |
Output is correct |
28 |
Correct |
45 ms |
2196 KB |
Output is correct |
29 |
Correct |
16 ms |
2196 KB |
Output is correct |
30 |
Correct |
4 ms |
2196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1404 KB |
Output is correct |
2 |
Correct |
11 ms |
1404 KB |
Output is correct |
3 |
Correct |
21 ms |
1404 KB |
Output is correct |
4 |
Correct |
23 ms |
1404 KB |
Output is correct |
5 |
Correct |
30 ms |
1404 KB |
Output is correct |
6 |
Correct |
23 ms |
1404 KB |
Output is correct |
7 |
Correct |
6 ms |
1404 KB |
Output is correct |
8 |
Correct |
17 ms |
1404 KB |
Output is correct |
9 |
Correct |
42 ms |
2004 KB |
Output is correct |
10 |
Correct |
25 ms |
2004 KB |
Output is correct |
11 |
Correct |
2 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
2004 KB |
Output is correct |
13 |
Correct |
2 ms |
2004 KB |
Output is correct |
14 |
Correct |
2 ms |
2004 KB |
Output is correct |
15 |
Correct |
2 ms |
2004 KB |
Output is correct |
16 |
Correct |
2 ms |
2004 KB |
Output is correct |
17 |
Correct |
2 ms |
2004 KB |
Output is correct |
18 |
Correct |
2 ms |
2004 KB |
Output is correct |
19 |
Correct |
2 ms |
2004 KB |
Output is correct |
20 |
Correct |
2 ms |
2004 KB |
Output is correct |
21 |
Correct |
3 ms |
2004 KB |
Output is correct |
22 |
Correct |
2 ms |
2004 KB |
Output is correct |
23 |
Correct |
3 ms |
2004 KB |
Output is correct |
24 |
Correct |
4 ms |
2004 KB |
Output is correct |
25 |
Correct |
3 ms |
2004 KB |
Output is correct |
26 |
Correct |
14 ms |
2004 KB |
Output is correct |
27 |
Correct |
62 ms |
2004 KB |
Output is correct |
28 |
Correct |
45 ms |
2196 KB |
Output is correct |
29 |
Correct |
54 ms |
2196 KB |
Output is correct |
30 |
Correct |
67 ms |
2196 KB |
Output is correct |
31 |
Correct |
71 ms |
2196 KB |
Output is correct |
32 |
Correct |
2 ms |
2196 KB |
Output is correct |
33 |
Correct |
22 ms |
2196 KB |
Output is correct |
34 |
Correct |
41 ms |
2196 KB |
Output is correct |
35 |
Correct |
9 ms |
2196 KB |
Output is correct |
36 |
Correct |
25 ms |
2196 KB |
Output is correct |
37 |
Correct |
30 ms |
2196 KB |
Output is correct |
38 |
Correct |
45 ms |
2196 KB |
Output is correct |
39 |
Correct |
16 ms |
2196 KB |
Output is correct |
40 |
Correct |
4 ms |
2196 KB |
Output is correct |
41 |
Correct |
59 ms |
2196 KB |
Output is correct |
42 |
Correct |
50 ms |
2196 KB |
Output is correct |
43 |
Correct |
49 ms |
2196 KB |
Output is correct |
44 |
Correct |
47 ms |
2196 KB |
Output is correct |
45 |
Correct |
49 ms |
2196 KB |
Output is correct |
46 |
Correct |
59 ms |
2196 KB |
Output is correct |
47 |
Correct |
50 ms |
2196 KB |
Output is correct |
48 |
Correct |
46 ms |
2196 KB |
Output is correct |
49 |
Correct |
40 ms |
2196 KB |
Output is correct |
50 |
Correct |
132 ms |
2196 KB |
Output is correct |
51 |
Correct |
142 ms |
2196 KB |
Output is correct |
52 |
Correct |
134 ms |
2196 KB |
Output is correct |
53 |
Correct |
161 ms |
2196 KB |
Output is correct |
54 |
Correct |
153 ms |
2196 KB |
Output is correct |
55 |
Correct |
138 ms |
2196 KB |
Output is correct |
56 |
Correct |
122 ms |
2196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
412 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
460 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
2 ms |
464 KB |
Output is correct |
9 |
Correct |
30 ms |
1404 KB |
Output is correct |
10 |
Correct |
11 ms |
1404 KB |
Output is correct |
11 |
Correct |
21 ms |
1404 KB |
Output is correct |
12 |
Correct |
23 ms |
1404 KB |
Output is correct |
13 |
Correct |
30 ms |
1404 KB |
Output is correct |
14 |
Correct |
23 ms |
1404 KB |
Output is correct |
15 |
Correct |
6 ms |
1404 KB |
Output is correct |
16 |
Correct |
17 ms |
1404 KB |
Output is correct |
17 |
Correct |
42 ms |
2004 KB |
Output is correct |
18 |
Correct |
25 ms |
2004 KB |
Output is correct |
19 |
Correct |
2 ms |
2004 KB |
Output is correct |
20 |
Correct |
2 ms |
2004 KB |
Output is correct |
21 |
Correct |
2 ms |
2004 KB |
Output is correct |
22 |
Correct |
2 ms |
2004 KB |
Output is correct |
23 |
Correct |
2 ms |
2004 KB |
Output is correct |
24 |
Correct |
2 ms |
2004 KB |
Output is correct |
25 |
Correct |
2 ms |
2004 KB |
Output is correct |
26 |
Correct |
2 ms |
2004 KB |
Output is correct |
27 |
Correct |
2 ms |
2004 KB |
Output is correct |
28 |
Correct |
2 ms |
2004 KB |
Output is correct |
29 |
Correct |
3 ms |
2004 KB |
Output is correct |
30 |
Correct |
2 ms |
2004 KB |
Output is correct |
31 |
Correct |
3 ms |
2004 KB |
Output is correct |
32 |
Correct |
4 ms |
2004 KB |
Output is correct |
33 |
Correct |
3 ms |
2004 KB |
Output is correct |
34 |
Correct |
14 ms |
2004 KB |
Output is correct |
35 |
Correct |
62 ms |
2004 KB |
Output is correct |
36 |
Correct |
45 ms |
2196 KB |
Output is correct |
37 |
Correct |
54 ms |
2196 KB |
Output is correct |
38 |
Correct |
67 ms |
2196 KB |
Output is correct |
39 |
Correct |
71 ms |
2196 KB |
Output is correct |
40 |
Correct |
2 ms |
2196 KB |
Output is correct |
41 |
Correct |
22 ms |
2196 KB |
Output is correct |
42 |
Correct |
41 ms |
2196 KB |
Output is correct |
43 |
Correct |
9 ms |
2196 KB |
Output is correct |
44 |
Correct |
25 ms |
2196 KB |
Output is correct |
45 |
Correct |
30 ms |
2196 KB |
Output is correct |
46 |
Correct |
45 ms |
2196 KB |
Output is correct |
47 |
Correct |
16 ms |
2196 KB |
Output is correct |
48 |
Correct |
4 ms |
2196 KB |
Output is correct |
49 |
Correct |
59 ms |
2196 KB |
Output is correct |
50 |
Correct |
50 ms |
2196 KB |
Output is correct |
51 |
Correct |
49 ms |
2196 KB |
Output is correct |
52 |
Correct |
47 ms |
2196 KB |
Output is correct |
53 |
Correct |
49 ms |
2196 KB |
Output is correct |
54 |
Correct |
59 ms |
2196 KB |
Output is correct |
55 |
Correct |
50 ms |
2196 KB |
Output is correct |
56 |
Correct |
46 ms |
2196 KB |
Output is correct |
57 |
Correct |
40 ms |
2196 KB |
Output is correct |
58 |
Correct |
132 ms |
2196 KB |
Output is correct |
59 |
Correct |
142 ms |
2196 KB |
Output is correct |
60 |
Correct |
134 ms |
2196 KB |
Output is correct |
61 |
Correct |
161 ms |
2196 KB |
Output is correct |
62 |
Correct |
153 ms |
2196 KB |
Output is correct |
63 |
Correct |
138 ms |
2196 KB |
Output is correct |
64 |
Correct |
122 ms |
2196 KB |
Output is correct |
65 |
Correct |
2 ms |
2196 KB |
Output is correct |
66 |
Incorrect |
2 ms |
2196 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |