#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
/*
6 8
3 3 3 3
1 2 1 2
3 4 3 4
5 5 5 5
4 3 4 3
4 4 4 4
2 1 2 1
3 6 3 6
*/
ll C(ll x1, ll y1, ll x2, ll y2, ll a){
ll X = (x1 / a);
ll Y = (y1 / a);
if((X + Y) & 1) return 1;
return -1;
}
int main(){
// freopen("school.in", "r", stdin);
// freopen("school.out", "w", stdout);
ll n, k;
cin >> n >> k;
ll x1[k + 1], x2[k + 1], y1[k + 1], y2[k + 1];
for(int i = 1; i <= k; ++i){
cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
x1[i]--;
y1[i]--;
x2[i]--;
y2[i]--;
}
ll ans = 1e18 + 1;
for(int a = 1; a <n; a++){
if(n % a) continue;
ll v = n / a;
ll cnt = 0;
if(v % 2 == 1)
cnt += v * (v / 2) + (v + 1) / 2;
else cnt = v * v / 2;
cnt *= a * a;
for(int i = 1; i <= k; i++){
ll X = (x1 / a);
ll Y = (y1 / a);
if((X + Y) & 1) cnt++;
cnt--;
}
ans = min(ans, cnt);
}
for(ll a = 1; a <n; a++){
if(n % a) continue;
ll v = n / a;
ll cnt = -1;
if(v % 2 == 1)
cnt += v * (v / 2) + (v + 1) / 2;
else cnt = v * v / 2;
cnt *= a * a;
for(int i = 1; i <= k; i++){
ll X = (x1 / a);
ll Y = (y1 / a);
if((X + Y) & 1) cnt--;
cnt++;
}
ans = min(ans, cnt);
}
cout << ans;
return 0;
}
Compilation message
chessboard.cpp: In function 'int main()':
chessboard.cpp:57:24: error: invalid operands of types 'long long int [(k + 1)]' and 'int' to binary 'operator/'
57 | ll X = (x1 / a);
| ~~ ^ ~
| | |
| | int
| long long int [(k + 1)]
chessboard.cpp:58:24: error: invalid operands of types 'long long int [(k + 1)]' and 'int' to binary 'operator/'
58 | ll Y = (y1 / a);
| ~~ ^ ~
| | |
| | int
| long long int [(k + 1)]
chessboard.cpp:73:24: error: invalid operands of types 'long long int [(k + 1)]' and 'long long int' to binary 'operator/'
73 | ll X = (x1 / a);
| ~~ ^ ~
| | |
| | long long int
| long long int [(k + 1)]
chessboard.cpp:74:24: error: invalid operands of types 'long long int [(k + 1)]' and 'long long int' to binary 'operator/'
74 | ll Y = (y1 / a);
| ~~ ^ ~
| | |
| | long long int
| long long int [(k + 1)]