/* Murad Eynizade */
#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);
using namespace std;
struct rect{
int a , b , c , d;
};
rect sub[SIZE];
intt need;
vector<intt>ans;
int n , k;
vector<int>dv;
int main()
{
FAST_READ;
cin>>n>>k;
for (int i = 0;i<k;i++)cin>>sub[i].a>>sub[i].b>>sub[i].c>>sub[i].d;
dv.push_back(1);
for (int i = 2;i * i <= n;i++) {
if (n % i == 0) {
dv.push_back(i);
if (i * i == n)continue;
dv.push_back(n / i);
}
}
for (int i : dv) {
need = ( (n / i + i) / 2 ) * ( (n / i + i) / 2 );
need += (n / i / 2) * (n / i / 2);
need *= (i * i);
for (int j = 0;j < k;j++) {
int row , column;
if (sub[j].a % i == 0)row = sub[j].a / i;
else row = (sub[j].a + i) / i;
if (sub[j].b % i == 0)column = sub[j].b / i;
else column = (sub[j].b + i) / i;
if (row % 2 == column % 2) need--;
else need++;
}
ans.push_back(need);
}
sort(ans.begin(),ans.end());
cout<<ans[0]<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2808 KB |
Output is correct |
2 |
Incorrect |
7 ms |
1016 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2808 KB |
Output is correct |
2 |
Incorrect |
7 ms |
1016 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |