#include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
using namespace std;
const long long INF = 2e11;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 10;
const long long Z = 5e4 + 10;
ll n, k, ans = INF;
ll cor[N][4];
ll count(ll m)
{
ll ret1 = ((n / m) * (n / m) / 2 + (n / m) * (n / m) % 2) * m * m;
ll ret2 = ((n / m) * (n / m) / 2) * m * m;
for (int i = 1; i <= k; i++){
ll r = cor[i][2] / m + (cor[i][2] % m != 0);
ll c = cor[i][3] / m + (cor[i][3] % m != 0);
if((c + r) % 2 == 0){
ret1--;
ret2++;
}
else{
ret1++;
ret2--;
}
}
return min(ret1, ret2);
}
void solve()
{
cin >> n >> k;
for (int i = 1 ; i <= k; i++)
for (int j = 0; j < 4; j++)cin >> cor[i][j];
for (int i = 1; i < n; i++){
if(n % i != 0)
continue;
ans = min(ans, count((ll) i));
}
cout << ans;
}
int main()
{
int TE = 1;
ios_base::sync_with_stdio(false);
//freopen("photo.in", "r", stdin);
//freopen("photo.out", "w", stdout);
//cin >> TE;
while(TE --){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
2 ms |
520 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
700 KB |
Output is correct |
8 |
Correct |
2 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
2504 KB |
Output is correct |
2 |
Correct |
10 ms |
2504 KB |
Output is correct |
3 |
Correct |
23 ms |
2808 KB |
Output is correct |
4 |
Correct |
23 ms |
3876 KB |
Output is correct |
5 |
Correct |
30 ms |
5380 KB |
Output is correct |
6 |
Correct |
20 ms |
5776 KB |
Output is correct |
7 |
Correct |
6 ms |
5776 KB |
Output is correct |
8 |
Correct |
19 ms |
6552 KB |
Output is correct |
9 |
Correct |
49 ms |
10348 KB |
Output is correct |
10 |
Correct |
27 ms |
10348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10348 KB |
Output is correct |
2 |
Correct |
2 ms |
10348 KB |
Output is correct |
3 |
Correct |
2 ms |
10348 KB |
Output is correct |
4 |
Correct |
3 ms |
10348 KB |
Output is correct |
5 |
Correct |
2 ms |
10348 KB |
Output is correct |
6 |
Correct |
2 ms |
10348 KB |
Output is correct |
7 |
Correct |
3 ms |
10348 KB |
Output is correct |
8 |
Correct |
2 ms |
10348 KB |
Output is correct |
9 |
Correct |
2 ms |
10348 KB |
Output is correct |
10 |
Correct |
2 ms |
10348 KB |
Output is correct |
11 |
Correct |
2 ms |
10348 KB |
Output is correct |
12 |
Correct |
2 ms |
10348 KB |
Output is correct |
13 |
Correct |
3 ms |
10348 KB |
Output is correct |
14 |
Correct |
3 ms |
10348 KB |
Output is correct |
15 |
Correct |
3 ms |
10348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10348 KB |
Output is correct |
2 |
Correct |
2 ms |
10348 KB |
Output is correct |
3 |
Correct |
2 ms |
10348 KB |
Output is correct |
4 |
Correct |
3 ms |
10348 KB |
Output is correct |
5 |
Correct |
2 ms |
10348 KB |
Output is correct |
6 |
Correct |
2 ms |
10348 KB |
Output is correct |
7 |
Correct |
3 ms |
10348 KB |
Output is correct |
8 |
Correct |
2 ms |
10348 KB |
Output is correct |
9 |
Correct |
2 ms |
10348 KB |
Output is correct |
10 |
Correct |
2 ms |
10348 KB |
Output is correct |
11 |
Correct |
2 ms |
10348 KB |
Output is correct |
12 |
Correct |
2 ms |
10348 KB |
Output is correct |
13 |
Correct |
3 ms |
10348 KB |
Output is correct |
14 |
Correct |
3 ms |
10348 KB |
Output is correct |
15 |
Correct |
3 ms |
10348 KB |
Output is correct |
16 |
Correct |
16 ms |
10348 KB |
Output is correct |
17 |
Correct |
38 ms |
13288 KB |
Output is correct |
18 |
Correct |
50 ms |
15280 KB |
Output is correct |
19 |
Correct |
125 ms |
16496 KB |
Output is correct |
20 |
Correct |
134 ms |
18300 KB |
Output is correct |
21 |
Correct |
35 ms |
19128 KB |
Output is correct |
22 |
Correct |
2 ms |
19128 KB |
Output is correct |
23 |
Correct |
29 ms |
19128 KB |
Output is correct |
24 |
Correct |
46 ms |
21648 KB |
Output is correct |
25 |
Correct |
8 ms |
21648 KB |
Output is correct |
26 |
Correct |
31 ms |
21648 KB |
Output is correct |
27 |
Correct |
44 ms |
23012 KB |
Output is correct |
28 |
Correct |
49 ms |
25128 KB |
Output is correct |
29 |
Correct |
16 ms |
25128 KB |
Output is correct |
30 |
Correct |
3 ms |
25128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
2504 KB |
Output is correct |
2 |
Correct |
10 ms |
2504 KB |
Output is correct |
3 |
Correct |
23 ms |
2808 KB |
Output is correct |
4 |
Correct |
23 ms |
3876 KB |
Output is correct |
5 |
Correct |
30 ms |
5380 KB |
Output is correct |
6 |
Correct |
20 ms |
5776 KB |
Output is correct |
7 |
Correct |
6 ms |
5776 KB |
Output is correct |
8 |
Correct |
19 ms |
6552 KB |
Output is correct |
9 |
Correct |
49 ms |
10348 KB |
Output is correct |
10 |
Correct |
27 ms |
10348 KB |
Output is correct |
11 |
Correct |
2 ms |
10348 KB |
Output is correct |
12 |
Correct |
2 ms |
10348 KB |
Output is correct |
13 |
Correct |
2 ms |
10348 KB |
Output is correct |
14 |
Correct |
3 ms |
10348 KB |
Output is correct |
15 |
Correct |
2 ms |
10348 KB |
Output is correct |
16 |
Correct |
2 ms |
10348 KB |
Output is correct |
17 |
Correct |
3 ms |
10348 KB |
Output is correct |
18 |
Correct |
2 ms |
10348 KB |
Output is correct |
19 |
Correct |
2 ms |
10348 KB |
Output is correct |
20 |
Correct |
2 ms |
10348 KB |
Output is correct |
21 |
Correct |
2 ms |
10348 KB |
Output is correct |
22 |
Correct |
2 ms |
10348 KB |
Output is correct |
23 |
Correct |
3 ms |
10348 KB |
Output is correct |
24 |
Correct |
3 ms |
10348 KB |
Output is correct |
25 |
Correct |
3 ms |
10348 KB |
Output is correct |
26 |
Correct |
16 ms |
10348 KB |
Output is correct |
27 |
Correct |
38 ms |
13288 KB |
Output is correct |
28 |
Correct |
50 ms |
15280 KB |
Output is correct |
29 |
Correct |
125 ms |
16496 KB |
Output is correct |
30 |
Correct |
134 ms |
18300 KB |
Output is correct |
31 |
Correct |
35 ms |
19128 KB |
Output is correct |
32 |
Correct |
2 ms |
19128 KB |
Output is correct |
33 |
Correct |
29 ms |
19128 KB |
Output is correct |
34 |
Correct |
46 ms |
21648 KB |
Output is correct |
35 |
Correct |
8 ms |
21648 KB |
Output is correct |
36 |
Correct |
31 ms |
21648 KB |
Output is correct |
37 |
Correct |
44 ms |
23012 KB |
Output is correct |
38 |
Correct |
49 ms |
25128 KB |
Output is correct |
39 |
Correct |
16 ms |
25128 KB |
Output is correct |
40 |
Correct |
3 ms |
25128 KB |
Output is correct |
41 |
Correct |
110 ms |
25128 KB |
Output is correct |
42 |
Correct |
57 ms |
25200 KB |
Output is correct |
43 |
Correct |
73 ms |
25200 KB |
Output is correct |
44 |
Correct |
54 ms |
25200 KB |
Output is correct |
45 |
Correct |
53 ms |
26780 KB |
Output is correct |
46 |
Correct |
123 ms |
28828 KB |
Output is correct |
47 |
Correct |
44 ms |
30392 KB |
Output is correct |
48 |
Correct |
64 ms |
32340 KB |
Output is correct |
49 |
Correct |
50 ms |
34256 KB |
Output is correct |
50 |
Correct |
477 ms |
36656 KB |
Output is correct |
51 |
Correct |
489 ms |
39180 KB |
Output is correct |
52 |
Correct |
456 ms |
41088 KB |
Output is correct |
53 |
Correct |
491 ms |
43632 KB |
Output is correct |
54 |
Correct |
451 ms |
45540 KB |
Output is correct |
55 |
Correct |
513 ms |
46124 KB |
Output is correct |
56 |
Correct |
438 ms |
46124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
2 ms |
520 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
700 KB |
Output is correct |
8 |
Correct |
2 ms |
700 KB |
Output is correct |
9 |
Correct |
32 ms |
2504 KB |
Output is correct |
10 |
Correct |
10 ms |
2504 KB |
Output is correct |
11 |
Correct |
23 ms |
2808 KB |
Output is correct |
12 |
Correct |
23 ms |
3876 KB |
Output is correct |
13 |
Correct |
30 ms |
5380 KB |
Output is correct |
14 |
Correct |
20 ms |
5776 KB |
Output is correct |
15 |
Correct |
6 ms |
5776 KB |
Output is correct |
16 |
Correct |
19 ms |
6552 KB |
Output is correct |
17 |
Correct |
49 ms |
10348 KB |
Output is correct |
18 |
Correct |
27 ms |
10348 KB |
Output is correct |
19 |
Correct |
2 ms |
10348 KB |
Output is correct |
20 |
Correct |
2 ms |
10348 KB |
Output is correct |
21 |
Correct |
2 ms |
10348 KB |
Output is correct |
22 |
Correct |
3 ms |
10348 KB |
Output is correct |
23 |
Correct |
2 ms |
10348 KB |
Output is correct |
24 |
Correct |
2 ms |
10348 KB |
Output is correct |
25 |
Correct |
3 ms |
10348 KB |
Output is correct |
26 |
Correct |
2 ms |
10348 KB |
Output is correct |
27 |
Correct |
2 ms |
10348 KB |
Output is correct |
28 |
Correct |
2 ms |
10348 KB |
Output is correct |
29 |
Correct |
2 ms |
10348 KB |
Output is correct |
30 |
Correct |
2 ms |
10348 KB |
Output is correct |
31 |
Correct |
3 ms |
10348 KB |
Output is correct |
32 |
Correct |
3 ms |
10348 KB |
Output is correct |
33 |
Correct |
3 ms |
10348 KB |
Output is correct |
34 |
Correct |
16 ms |
10348 KB |
Output is correct |
35 |
Correct |
38 ms |
13288 KB |
Output is correct |
36 |
Correct |
50 ms |
15280 KB |
Output is correct |
37 |
Correct |
125 ms |
16496 KB |
Output is correct |
38 |
Correct |
134 ms |
18300 KB |
Output is correct |
39 |
Correct |
35 ms |
19128 KB |
Output is correct |
40 |
Correct |
2 ms |
19128 KB |
Output is correct |
41 |
Correct |
29 ms |
19128 KB |
Output is correct |
42 |
Correct |
46 ms |
21648 KB |
Output is correct |
43 |
Correct |
8 ms |
21648 KB |
Output is correct |
44 |
Correct |
31 ms |
21648 KB |
Output is correct |
45 |
Correct |
44 ms |
23012 KB |
Output is correct |
46 |
Correct |
49 ms |
25128 KB |
Output is correct |
47 |
Correct |
16 ms |
25128 KB |
Output is correct |
48 |
Correct |
3 ms |
25128 KB |
Output is correct |
49 |
Correct |
110 ms |
25128 KB |
Output is correct |
50 |
Correct |
57 ms |
25200 KB |
Output is correct |
51 |
Correct |
73 ms |
25200 KB |
Output is correct |
52 |
Correct |
54 ms |
25200 KB |
Output is correct |
53 |
Correct |
53 ms |
26780 KB |
Output is correct |
54 |
Correct |
123 ms |
28828 KB |
Output is correct |
55 |
Correct |
44 ms |
30392 KB |
Output is correct |
56 |
Correct |
64 ms |
32340 KB |
Output is correct |
57 |
Correct |
50 ms |
34256 KB |
Output is correct |
58 |
Correct |
477 ms |
36656 KB |
Output is correct |
59 |
Correct |
489 ms |
39180 KB |
Output is correct |
60 |
Correct |
456 ms |
41088 KB |
Output is correct |
61 |
Correct |
491 ms |
43632 KB |
Output is correct |
62 |
Correct |
451 ms |
45540 KB |
Output is correct |
63 |
Correct |
513 ms |
46124 KB |
Output is correct |
64 |
Correct |
438 ms |
46124 KB |
Output is correct |
65 |
Correct |
2 ms |
46124 KB |
Output is correct |
66 |
Incorrect |
2 ms |
46124 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |