#include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 1e5 + 25;
const ll maxl = 22 + 0;
const ll inf = 2e9 + 0;
const ll mod = 998244353;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
ll n, k;
struct rect
{
ll x1, y1, x2, y2;
} q[maxn];
vector <ll> f(ll x)
{
vector <ll> res;
res.pb(1);
for (ll i = 2; i * i <= x; ++i)
{
if (x % i == 0)
{
res.pb(i);
if (x % (x / i) == 0 && i != x / i) res.pb(x / i);
}
}
return res;
}
void ma1n ()
{
cin >> n >> k;
for (ll i = 1; i <= k; ++i)
{
cin >> q[i].x1 >> q[i].y1 >> q[i].x2 >> q[i].y2;
}
vector <ll> d = f(n);
ll ans = n * n;
for (ll len : d)
{
ll cnt0 = 0, cnt1 = 0;
for (ll i = 1; i <= k; ++i)
{
if (((q[i].x1 + len - 1) / len + (q[i].y1 + len - 1) / len) & 1) cnt1++;
else cnt0++;
}
ll sz = (n * n) / len / len;
ans = min(ans, len * len * (sz / 2) - cnt1 + cnt0);
ans = min(ans, len * len * ((sz + 1) / 2) - cnt0 + cnt1);
}
cout << ans << nl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("mooyomooyo.in", "r", stdin);
// freopen("mooyomooyo.out", "w", stdout);
int ttt = 1;
// cin >> ttt;
for (int test = 1; test <= ttt; ++test)
{
// cout << "Case " << test << ":" << nl;
ma1n();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
2352 KB |
Output is correct |
2 |
Correct |
6 ms |
988 KB |
Output is correct |
3 |
Correct |
12 ms |
1596 KB |
Output is correct |
4 |
Correct |
14 ms |
1796 KB |
Output is correct |
5 |
Correct |
16 ms |
2140 KB |
Output is correct |
6 |
Correct |
12 ms |
1500 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
11 ms |
1480 KB |
Output is correct |
9 |
Correct |
26 ms |
3156 KB |
Output is correct |
10 |
Correct |
17 ms |
2004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
8 ms |
1236 KB |
Output is correct |
17 |
Correct |
22 ms |
3148 KB |
Output is correct |
18 |
Correct |
27 ms |
3660 KB |
Output is correct |
19 |
Correct |
54 ms |
3332 KB |
Output is correct |
20 |
Correct |
62 ms |
3760 KB |
Output is correct |
21 |
Correct |
21 ms |
3148 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
17 ms |
1884 KB |
Output is correct |
24 |
Correct |
25 ms |
3264 KB |
Output is correct |
25 |
Correct |
3 ms |
716 KB |
Output is correct |
26 |
Correct |
16 ms |
2272 KB |
Output is correct |
27 |
Correct |
21 ms |
2620 KB |
Output is correct |
28 |
Correct |
27 ms |
3496 KB |
Output is correct |
29 |
Correct |
10 ms |
1512 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
2352 KB |
Output is correct |
2 |
Correct |
6 ms |
988 KB |
Output is correct |
3 |
Correct |
12 ms |
1596 KB |
Output is correct |
4 |
Correct |
14 ms |
1796 KB |
Output is correct |
5 |
Correct |
16 ms |
2140 KB |
Output is correct |
6 |
Correct |
12 ms |
1500 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
11 ms |
1480 KB |
Output is correct |
9 |
Correct |
26 ms |
3156 KB |
Output is correct |
10 |
Correct |
17 ms |
2004 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
376 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
8 ms |
1236 KB |
Output is correct |
27 |
Correct |
22 ms |
3148 KB |
Output is correct |
28 |
Correct |
27 ms |
3660 KB |
Output is correct |
29 |
Correct |
54 ms |
3332 KB |
Output is correct |
30 |
Correct |
62 ms |
3760 KB |
Output is correct |
31 |
Correct |
21 ms |
3148 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
17 ms |
1884 KB |
Output is correct |
34 |
Correct |
25 ms |
3264 KB |
Output is correct |
35 |
Correct |
3 ms |
716 KB |
Output is correct |
36 |
Correct |
16 ms |
2272 KB |
Output is correct |
37 |
Correct |
21 ms |
2620 KB |
Output is correct |
38 |
Correct |
27 ms |
3496 KB |
Output is correct |
39 |
Correct |
10 ms |
1512 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
55 ms |
3112 KB |
Output is correct |
42 |
Correct |
31 ms |
5484 KB |
Output is correct |
43 |
Correct |
36 ms |
4876 KB |
Output is correct |
44 |
Correct |
30 ms |
5324 KB |
Output is correct |
45 |
Correct |
31 ms |
5624 KB |
Output is correct |
46 |
Correct |
58 ms |
5416 KB |
Output is correct |
47 |
Correct |
26 ms |
4924 KB |
Output is correct |
48 |
Correct |
34 ms |
5108 KB |
Output is correct |
49 |
Correct |
28 ms |
4940 KB |
Output is correct |
50 |
Correct |
193 ms |
5320 KB |
Output is correct |
51 |
Correct |
208 ms |
5656 KB |
Output is correct |
52 |
Correct |
197 ms |
5292 KB |
Output is correct |
53 |
Correct |
212 ms |
5660 KB |
Output is correct |
54 |
Correct |
187 ms |
5144 KB |
Output is correct |
55 |
Correct |
216 ms |
5772 KB |
Output is correct |
56 |
Correct |
194 ms |
5072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
19 ms |
2352 KB |
Output is correct |
10 |
Correct |
6 ms |
988 KB |
Output is correct |
11 |
Correct |
12 ms |
1596 KB |
Output is correct |
12 |
Correct |
14 ms |
1796 KB |
Output is correct |
13 |
Correct |
16 ms |
2140 KB |
Output is correct |
14 |
Correct |
12 ms |
1500 KB |
Output is correct |
15 |
Correct |
4 ms |
584 KB |
Output is correct |
16 |
Correct |
11 ms |
1480 KB |
Output is correct |
17 |
Correct |
26 ms |
3156 KB |
Output is correct |
18 |
Correct |
17 ms |
2004 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
376 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
8 ms |
1236 KB |
Output is correct |
35 |
Correct |
22 ms |
3148 KB |
Output is correct |
36 |
Correct |
27 ms |
3660 KB |
Output is correct |
37 |
Correct |
54 ms |
3332 KB |
Output is correct |
38 |
Correct |
62 ms |
3760 KB |
Output is correct |
39 |
Correct |
21 ms |
3148 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
17 ms |
1884 KB |
Output is correct |
42 |
Correct |
25 ms |
3264 KB |
Output is correct |
43 |
Correct |
3 ms |
716 KB |
Output is correct |
44 |
Correct |
16 ms |
2272 KB |
Output is correct |
45 |
Correct |
21 ms |
2620 KB |
Output is correct |
46 |
Correct |
27 ms |
3496 KB |
Output is correct |
47 |
Correct |
10 ms |
1512 KB |
Output is correct |
48 |
Correct |
1 ms |
340 KB |
Output is correct |
49 |
Correct |
55 ms |
3112 KB |
Output is correct |
50 |
Correct |
31 ms |
5484 KB |
Output is correct |
51 |
Correct |
36 ms |
4876 KB |
Output is correct |
52 |
Correct |
30 ms |
5324 KB |
Output is correct |
53 |
Correct |
31 ms |
5624 KB |
Output is correct |
54 |
Correct |
58 ms |
5416 KB |
Output is correct |
55 |
Correct |
26 ms |
4924 KB |
Output is correct |
56 |
Correct |
34 ms |
5108 KB |
Output is correct |
57 |
Correct |
28 ms |
4940 KB |
Output is correct |
58 |
Correct |
193 ms |
5320 KB |
Output is correct |
59 |
Correct |
208 ms |
5656 KB |
Output is correct |
60 |
Correct |
197 ms |
5292 KB |
Output is correct |
61 |
Correct |
212 ms |
5660 KB |
Output is correct |
62 |
Correct |
187 ms |
5144 KB |
Output is correct |
63 |
Correct |
216 ms |
5772 KB |
Output is correct |
64 |
Correct |
194 ms |
5072 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
67 |
Halted |
0 ms |
0 KB |
- |