#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k, cnt, x, y, xx, yy;
ll a[3][3];
ll di[50005][5][5];
vector <ll> d;
void subt_3_4_5()
{
ll mn = INT_MAX, a1, a2;
for ( int i = 1; i < n; i ++ ){
if ( n % i == 0 ) {
d.push_back( i );
}
}
for ( int i = 1; i <= k; i ++ ){
cin >> x >> y >> xx >> yy;
for ( auto e: d ) {
ll r, c;
r = (x/e) + ( (x%e) && 1 );
c = (y/e) + ( (y%e) && 1 );
di[e][r%2][c%2] ++;
}
}
for ( auto e: d ) {
a1 = a2 = 0;
for ( int i = 1; i <= (n/e); i ++ ) {
if ( i % 2 ) {
a1 += (e*e) * ((n/e)/2);
a2 += (e*e) * (((n/e)+1)/2);
}
else {
a2 += (e*e) * ((n/e)/2);
a1 += (e*e) * (((n/e)+1)/2);
}
}
a1 -= di[e][1][0] + di[e][0][1];
a1 += di[e][0][0] + di[e][1][1];
a2 += di[e][1][0] + di[e][0][1];
a2 -= di[e][0][0] + di[e][1][1];
mn = min ( mn, min ( a1, a2 ) );
}
cout << mn;
exit(0);
}
int main()
{
cin >> n >> k;
subt_3_4_5();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
256 KB |
Output is correct |
2 |
Correct |
19 ms |
376 KB |
Output is correct |
3 |
Incorrect |
47 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
504 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
504 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
16 |
Correct |
26 ms |
256 KB |
Output is correct |
17 |
Correct |
72 ms |
396 KB |
Output is correct |
18 |
Correct |
107 ms |
368 KB |
Output is correct |
19 |
Correct |
126 ms |
376 KB |
Output is correct |
20 |
Correct |
144 ms |
436 KB |
Output is correct |
21 |
Correct |
70 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
372 KB |
Output is correct |
23 |
Correct |
43 ms |
376 KB |
Output is correct |
24 |
Correct |
80 ms |
256 KB |
Output is correct |
25 |
Correct |
10 ms |
376 KB |
Output is correct |
26 |
Correct |
52 ms |
256 KB |
Output is correct |
27 |
Correct |
64 ms |
408 KB |
Output is correct |
28 |
Correct |
85 ms |
376 KB |
Output is correct |
29 |
Correct |
30 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
256 KB |
Output is correct |
2 |
Correct |
19 ms |
376 KB |
Output is correct |
3 |
Incorrect |
47 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
72 ms |
256 KB |
Output is correct |
10 |
Correct |
19 ms |
376 KB |
Output is correct |
11 |
Incorrect |
47 ms |
376 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |