#include <bits/stdc++.h>
using namespace std;
#define int long long
const int NM = 1e5, inf = 1e18;
int N, K, x[NM+5], y[NM+5], ans = +inf;
int num[2];
void solve(int t){
num[0] = num[1] = 0;
for (int i = 1; i <= K; i++){
int blx = x[i]/t+(x[i]%t > 0), bly = y[i]/t+(y[i]%t > 0);
num[(blx+bly)%2]++;
}
int targ = t*t*(N*N/(t*t)/2);
cout << N << ' ' << t << ' ' << targ << endl;
ans = min(ans, abs(targ-num[0])+num[1]);
ans = min(ans, abs(targ-num[1])+num[0]);
ans = min(ans, abs(N*N-targ-num[0])+num[1]);
ans = min(ans, abs(N*N-targ-num[1])+num[0]);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
for (int i = 1; i <= K; i++){
cin >> x[i] >> y[i] >> x[i] >> y[i];
}
for (int i = 1; i*i <= N; i++)
if (N%i == 0){
solve(i);
if (i > 1) solve(N/i);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |