#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define oo 1e9
#define int ll
int n, k;
const int MAX = 1e5 + 5;
vector<pii> black;
vector<int> s;
void solve(){
cin >> n >> k;
for(int i = 1; i <= k; i++){
int a, b; cin >> a >> b >> a >> b;
black.push_back({a, b});
}
s.push_back(1);
for(int d = 2; d * d <= n; d++){
if(n % d == 0){
s.push_back(d);
if(n / d != d){
s.push_back(n / d);
}
}
}
int ans = oo;
for(int a : s){
int tmp1 = ((n / a) * (n / a) + 1) / 2 * a * a;
int tmp2 = ((n / a) * (n / a)) / 2 * a * a;
for(pii b : black){
int x = (b.first - 1) / a + 1;
int y = (b.second - 1) / a + 1;
if(x % 2 == y % 2){
tmp1--;
tmp2++;
}
else{
tmp1++;
tmp2--;
}
}
ans = min(tmp1, ans);
ans = min(tmp2, ans);
}
cout << ans << '\n';
}
signed main(){
int t = 1;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
444 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
476 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
444 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
476 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
17 ms |
1492 KB |
Output is correct |
17 |
Correct |
54 ms |
3508 KB |
Output is correct |
18 |
Correct |
63 ms |
3308 KB |
Output is correct |
19 |
Correct |
87 ms |
3272 KB |
Output is correct |
20 |
Correct |
92 ms |
3264 KB |
Output is correct |
21 |
Correct |
48 ms |
3528 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
29 ms |
2068 KB |
Output is correct |
24 |
Correct |
63 ms |
3268 KB |
Output is correct |
25 |
Correct |
6 ms |
792 KB |
Output is correct |
26 |
Correct |
35 ms |
1996 KB |
Output is correct |
27 |
Correct |
45 ms |
3240 KB |
Output is correct |
28 |
Correct |
59 ms |
3264 KB |
Output is correct |
29 |
Correct |
20 ms |
2112 KB |
Output is correct |
30 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
2504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
49 ms |
2504 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |