#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#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 |
51 ms |
1460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
17 ms |
984 KB |
Output is correct |
17 |
Correct |
49 ms |
2504 KB |
Output is correct |
18 |
Correct |
60 ms |
2500 KB |
Output is correct |
19 |
Correct |
87 ms |
3016 KB |
Output is correct |
20 |
Correct |
91 ms |
2508 KB |
Output is correct |
21 |
Correct |
47 ms |
2500 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
28 ms |
1492 KB |
Output is correct |
24 |
Correct |
55 ms |
2504 KB |
Output is correct |
25 |
Correct |
6 ms |
604 KB |
Output is correct |
26 |
Correct |
45 ms |
1532 KB |
Output is correct |
27 |
Correct |
49 ms |
2500 KB |
Output is correct |
28 |
Correct |
57 ms |
2512 KB |
Output is correct |
29 |
Correct |
19 ms |
1480 KB |
Output is correct |
30 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1460 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 |
51 ms |
1460 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |