This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int a[100000], b[100000], x2[100000], y2[100000];
int main() {
int n, k;
long long ansT, ans = 10000000000LL;
cin>>n>>k;
for(int i = 0; i < k; ++i) {
cin>>a[i]>>b[i]>>x2[i]>>y2[i];
a[i]--;b[i]--;
x2[i]--;y2[i]--;
}
for(int j = 1; j < n; ++j)
if(n % j == 0) {
ansT = 0;
for(int i = 0; i < k; ++i)
if((a[i]/j + b[i]/j) % 2 == 0)
++ansT;
ansT = ansT * 2 - k;
if(ansT + (long long)n * n / j / j / 2 * j * j < ans)
ans = ansT + (long long)n * n / j / j / 2 * j * j;
ansT = -ansT;
if(ansT + ((long long)n * n / j / j + 1) / 2 * j * j < ans)
ans = ansT + ((long long)n * n / j / j + 1) / 2 * j * j;
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |