# include <stdio.h>
# include <bits/stdc++.h>
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y) for (int i = x; i <= y; i ++)
#define FOr(i,x,y) for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define x1 dlp
#define y1 kdkdf
// ROAD to... Red
using namespace std;
inline bool isvowel (char c) {
c = tolower(c);
if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
return 0;
}
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n, k;
int x1[N], y1[N], x2[N], y2[N];
ll cell (ll x, ll y, ll m) {
x --, y --;
x /= m, y /= m;
return x + y;
}
ll solve (ll x) {
ll res = ((n / x * (ll)n / x) / 2ll) * x * x;
ll ans = n * (ll) n - res;
// cout << res << ' ' << ans << '\n';
For (i, 1, k) {
if (cell(x1[i], y1[i], x) % 2 == 1) ans ++, res --;
else res ++, ans --;
}
return min(res, ans);
}
int main () {
cin >> n >> k;
For (i, 1, k) {
cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
}
ll ans = n * (ll)n;
For (i, 1, n - 1) {
if (n % i == 0)
ans = min(ans, solve (i));
}
cout << ans;
return Accepted;
}
// Coded By OB
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
584 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
2996 KB |
Output is correct |
2 |
Correct |
24 ms |
2996 KB |
Output is correct |
3 |
Correct |
65 ms |
3996 KB |
Output is correct |
4 |
Correct |
58 ms |
4988 KB |
Output is correct |
5 |
Correct |
82 ms |
6508 KB |
Output is correct |
6 |
Correct |
52 ms |
7088 KB |
Output is correct |
7 |
Correct |
12 ms |
7088 KB |
Output is correct |
8 |
Correct |
52 ms |
8156 KB |
Output is correct |
9 |
Correct |
131 ms |
11028 KB |
Output is correct |
10 |
Correct |
74 ms |
11564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
11564 KB |
Output is correct |
2 |
Correct |
2 ms |
11564 KB |
Output is correct |
3 |
Correct |
2 ms |
11564 KB |
Output is correct |
4 |
Correct |
3 ms |
11564 KB |
Output is correct |
5 |
Correct |
3 ms |
11564 KB |
Output is correct |
6 |
Correct |
2 ms |
11564 KB |
Output is correct |
7 |
Correct |
4 ms |
11564 KB |
Output is correct |
8 |
Correct |
3 ms |
11564 KB |
Output is correct |
9 |
Correct |
2 ms |
11564 KB |
Output is correct |
10 |
Correct |
2 ms |
11564 KB |
Output is correct |
11 |
Correct |
3 ms |
11564 KB |
Output is correct |
12 |
Correct |
3 ms |
11564 KB |
Output is correct |
13 |
Correct |
3 ms |
11564 KB |
Output is correct |
14 |
Correct |
3 ms |
11564 KB |
Output is correct |
15 |
Correct |
3 ms |
11564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
11564 KB |
Output is correct |
2 |
Correct |
2 ms |
11564 KB |
Output is correct |
3 |
Correct |
2 ms |
11564 KB |
Output is correct |
4 |
Correct |
3 ms |
11564 KB |
Output is correct |
5 |
Correct |
3 ms |
11564 KB |
Output is correct |
6 |
Correct |
2 ms |
11564 KB |
Output is correct |
7 |
Correct |
4 ms |
11564 KB |
Output is correct |
8 |
Correct |
3 ms |
11564 KB |
Output is correct |
9 |
Correct |
2 ms |
11564 KB |
Output is correct |
10 |
Correct |
2 ms |
11564 KB |
Output is correct |
11 |
Correct |
3 ms |
11564 KB |
Output is correct |
12 |
Correct |
3 ms |
11564 KB |
Output is correct |
13 |
Correct |
3 ms |
11564 KB |
Output is correct |
14 |
Correct |
3 ms |
11564 KB |
Output is correct |
15 |
Correct |
3 ms |
11564 KB |
Output is correct |
16 |
Correct |
34 ms |
11820 KB |
Output is correct |
17 |
Correct |
94 ms |
14052 KB |
Output is correct |
18 |
Correct |
122 ms |
15864 KB |
Output is correct |
19 |
Correct |
184 ms |
17276 KB |
Output is correct |
20 |
Correct |
201 ms |
18984 KB |
Output is correct |
21 |
Correct |
89 ms |
19976 KB |
Output is correct |
22 |
Correct |
3 ms |
19976 KB |
Output is correct |
23 |
Correct |
56 ms |
20016 KB |
Output is correct |
24 |
Correct |
103 ms |
22268 KB |
Output is correct |
25 |
Correct |
13 ms |
22268 KB |
Output is correct |
26 |
Correct |
66 ms |
23080 KB |
Output is correct |
27 |
Correct |
84 ms |
24096 KB |
Output is correct |
28 |
Correct |
109 ms |
26080 KB |
Output is correct |
29 |
Correct |
37 ms |
26080 KB |
Output is correct |
30 |
Correct |
5 ms |
26080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
2996 KB |
Output is correct |
2 |
Correct |
24 ms |
2996 KB |
Output is correct |
3 |
Correct |
65 ms |
3996 KB |
Output is correct |
4 |
Correct |
58 ms |
4988 KB |
Output is correct |
5 |
Correct |
82 ms |
6508 KB |
Output is correct |
6 |
Correct |
52 ms |
7088 KB |
Output is correct |
7 |
Correct |
12 ms |
7088 KB |
Output is correct |
8 |
Correct |
52 ms |
8156 KB |
Output is correct |
9 |
Correct |
131 ms |
11028 KB |
Output is correct |
10 |
Correct |
74 ms |
11564 KB |
Output is correct |
11 |
Correct |
2 ms |
11564 KB |
Output is correct |
12 |
Correct |
2 ms |
11564 KB |
Output is correct |
13 |
Correct |
2 ms |
11564 KB |
Output is correct |
14 |
Correct |
3 ms |
11564 KB |
Output is correct |
15 |
Correct |
3 ms |
11564 KB |
Output is correct |
16 |
Correct |
2 ms |
11564 KB |
Output is correct |
17 |
Correct |
4 ms |
11564 KB |
Output is correct |
18 |
Correct |
3 ms |
11564 KB |
Output is correct |
19 |
Correct |
2 ms |
11564 KB |
Output is correct |
20 |
Correct |
2 ms |
11564 KB |
Output is correct |
21 |
Correct |
3 ms |
11564 KB |
Output is correct |
22 |
Correct |
3 ms |
11564 KB |
Output is correct |
23 |
Correct |
3 ms |
11564 KB |
Output is correct |
24 |
Correct |
3 ms |
11564 KB |
Output is correct |
25 |
Correct |
3 ms |
11564 KB |
Output is correct |
26 |
Correct |
34 ms |
11820 KB |
Output is correct |
27 |
Correct |
94 ms |
14052 KB |
Output is correct |
28 |
Correct |
122 ms |
15864 KB |
Output is correct |
29 |
Correct |
184 ms |
17276 KB |
Output is correct |
30 |
Correct |
201 ms |
18984 KB |
Output is correct |
31 |
Correct |
89 ms |
19976 KB |
Output is correct |
32 |
Correct |
3 ms |
19976 KB |
Output is correct |
33 |
Correct |
56 ms |
20016 KB |
Output is correct |
34 |
Correct |
103 ms |
22268 KB |
Output is correct |
35 |
Correct |
13 ms |
22268 KB |
Output is correct |
36 |
Correct |
66 ms |
23080 KB |
Output is correct |
37 |
Correct |
84 ms |
24096 KB |
Output is correct |
38 |
Correct |
109 ms |
26080 KB |
Output is correct |
39 |
Correct |
37 ms |
26080 KB |
Output is correct |
40 |
Correct |
5 ms |
26080 KB |
Output is correct |
41 |
Correct |
187 ms |
28480 KB |
Output is correct |
42 |
Correct |
146 ms |
30884 KB |
Output is correct |
43 |
Correct |
154 ms |
32628 KB |
Output is correct |
44 |
Correct |
141 ms |
35044 KB |
Output is correct |
45 |
Correct |
143 ms |
37456 KB |
Output is correct |
46 |
Correct |
221 ms |
39740 KB |
Output is correct |
47 |
Correct |
126 ms |
41536 KB |
Output is correct |
48 |
Correct |
148 ms |
43792 KB |
Output is correct |
49 |
Correct |
131 ms |
45656 KB |
Output is correct |
50 |
Correct |
545 ms |
48108 KB |
Output is correct |
51 |
Correct |
602 ms |
50408 KB |
Output is correct |
52 |
Correct |
542 ms |
52460 KB |
Output is correct |
53 |
Correct |
584 ms |
54740 KB |
Output is correct |
54 |
Correct |
543 ms |
56928 KB |
Output is correct |
55 |
Correct |
601 ms |
59444 KB |
Output is correct |
56 |
Correct |
526 ms |
61192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
584 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
592 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
612 KB |
Output is correct |
9 |
Correct |
92 ms |
2996 KB |
Output is correct |
10 |
Correct |
24 ms |
2996 KB |
Output is correct |
11 |
Correct |
65 ms |
3996 KB |
Output is correct |
12 |
Correct |
58 ms |
4988 KB |
Output is correct |
13 |
Correct |
82 ms |
6508 KB |
Output is correct |
14 |
Correct |
52 ms |
7088 KB |
Output is correct |
15 |
Correct |
12 ms |
7088 KB |
Output is correct |
16 |
Correct |
52 ms |
8156 KB |
Output is correct |
17 |
Correct |
131 ms |
11028 KB |
Output is correct |
18 |
Correct |
74 ms |
11564 KB |
Output is correct |
19 |
Correct |
2 ms |
11564 KB |
Output is correct |
20 |
Correct |
2 ms |
11564 KB |
Output is correct |
21 |
Correct |
2 ms |
11564 KB |
Output is correct |
22 |
Correct |
3 ms |
11564 KB |
Output is correct |
23 |
Correct |
3 ms |
11564 KB |
Output is correct |
24 |
Correct |
2 ms |
11564 KB |
Output is correct |
25 |
Correct |
4 ms |
11564 KB |
Output is correct |
26 |
Correct |
3 ms |
11564 KB |
Output is correct |
27 |
Correct |
2 ms |
11564 KB |
Output is correct |
28 |
Correct |
2 ms |
11564 KB |
Output is correct |
29 |
Correct |
3 ms |
11564 KB |
Output is correct |
30 |
Correct |
3 ms |
11564 KB |
Output is correct |
31 |
Correct |
3 ms |
11564 KB |
Output is correct |
32 |
Correct |
3 ms |
11564 KB |
Output is correct |
33 |
Correct |
3 ms |
11564 KB |
Output is correct |
34 |
Correct |
34 ms |
11820 KB |
Output is correct |
35 |
Correct |
94 ms |
14052 KB |
Output is correct |
36 |
Correct |
122 ms |
15864 KB |
Output is correct |
37 |
Correct |
184 ms |
17276 KB |
Output is correct |
38 |
Correct |
201 ms |
18984 KB |
Output is correct |
39 |
Correct |
89 ms |
19976 KB |
Output is correct |
40 |
Correct |
3 ms |
19976 KB |
Output is correct |
41 |
Correct |
56 ms |
20016 KB |
Output is correct |
42 |
Correct |
103 ms |
22268 KB |
Output is correct |
43 |
Correct |
13 ms |
22268 KB |
Output is correct |
44 |
Correct |
66 ms |
23080 KB |
Output is correct |
45 |
Correct |
84 ms |
24096 KB |
Output is correct |
46 |
Correct |
109 ms |
26080 KB |
Output is correct |
47 |
Correct |
37 ms |
26080 KB |
Output is correct |
48 |
Correct |
5 ms |
26080 KB |
Output is correct |
49 |
Correct |
187 ms |
28480 KB |
Output is correct |
50 |
Correct |
146 ms |
30884 KB |
Output is correct |
51 |
Correct |
154 ms |
32628 KB |
Output is correct |
52 |
Correct |
141 ms |
35044 KB |
Output is correct |
53 |
Correct |
143 ms |
37456 KB |
Output is correct |
54 |
Correct |
221 ms |
39740 KB |
Output is correct |
55 |
Correct |
126 ms |
41536 KB |
Output is correct |
56 |
Correct |
148 ms |
43792 KB |
Output is correct |
57 |
Correct |
131 ms |
45656 KB |
Output is correct |
58 |
Correct |
545 ms |
48108 KB |
Output is correct |
59 |
Correct |
602 ms |
50408 KB |
Output is correct |
60 |
Correct |
542 ms |
52460 KB |
Output is correct |
61 |
Correct |
584 ms |
54740 KB |
Output is correct |
62 |
Correct |
543 ms |
56928 KB |
Output is correct |
63 |
Correct |
601 ms |
59444 KB |
Output is correct |
64 |
Correct |
526 ms |
61192 KB |
Output is correct |
65 |
Correct |
2 ms |
61192 KB |
Output is correct |
66 |
Incorrect |
2 ms |
61192 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |