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;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n, k;
long long ansT, ans = 10000000000LL;
int a[100000], b[100000], x2[100000], y2[100000];
int main(){std::ios::sync_with_stdio(false);
cin>>n>>k;
for(long long i=0;i<k;i++)
{
cin>>a[i]>>b[i]>>x2[i]>>y2[i];
a[i]--,b[i]--,y2[i]--,x2[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<<ansT+K-ansS<<" "<<ansS+k-ansT<<endl;
cout<<ans<<endl;
}
/*
* *
* * * *
* * * *
* * * *
* * * *
* * *
* *
* *
* *
* *
* *
* *
* *
* *
*
*/
# | 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... |