#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k, x, y, xx, yy;
ll d, mn = INT_MAX;
ll ch ( ll del ) {
ll ans = 0;
if ( del == 1 ) {
return (n*n)/2;
}
for ( int i = 1; i <= (n/del); i ++ ) {
if ( i % 2 == 1 ) {
ans += (del*del) * ( (n/del) / 2 );
}
else {
ans += (del*del) * ( ( ( n/del )+1) / 2 );
}
}
return ans;
}
ll a[5][5];
void subt2()
{
for ( int i = 1; i <= k; i ++ ) {
cin >> x >> y >> xx >> yy;
a[x%2][y%2]++;
}
ll a1 = 0, a2 = 0;
a1 = (n*n) / 2;
a2 = a1 + 1;
a2 = a2 - (a[1][1] + a[0][0]);
a2 = a2 + (a[1][0] + a[0][1]);
a1 = a1 - (a[1][0] + a[0][1]);
a1 = a1 + (a[1][1] + a[0][0]);
cout << min ( (a1), (a2) );
}
int main()
{
cin >> n >> k;
ll cnt = 0;
for ( int i = 1; i <= n; i ++ )
if ( n % i == 0 ) cnt ++;
if ( cnt == 2 ){
subt2();
return 0;
}
for ( int i = 1; i < n; i ++ ) {
if ( n % i == 0 ) {
ll an = ch(i);
mn = min ( mn, an );
}
}
cout << mn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
256 KB |
Output is correct |
2 |
Correct |
19 ms |
632 KB |
Output is correct |
3 |
Correct |
48 ms |
1236 KB |
Output is correct |
4 |
Correct |
44 ms |
1112 KB |
Output is correct |
5 |
Correct |
64 ms |
1612 KB |
Output is correct |
6 |
Correct |
41 ms |
1144 KB |
Output is correct |
7 |
Correct |
10 ms |
632 KB |
Output is correct |
8 |
Correct |
40 ms |
1144 KB |
Output is correct |
9 |
Correct |
107 ms |
2424 KB |
Output is correct |
10 |
Correct |
58 ms |
1532 KB |
Output is correct |
# |
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 |
71 ms |
256 KB |
Output is correct |
2 |
Correct |
19 ms |
632 KB |
Output is correct |
3 |
Correct |
48 ms |
1236 KB |
Output is correct |
4 |
Correct |
44 ms |
1112 KB |
Output is correct |
5 |
Correct |
64 ms |
1612 KB |
Output is correct |
6 |
Correct |
41 ms |
1144 KB |
Output is correct |
7 |
Correct |
10 ms |
632 KB |
Output is correct |
8 |
Correct |
40 ms |
1144 KB |
Output is correct |
9 |
Correct |
107 ms |
2424 KB |
Output is correct |
10 |
Correct |
58 ms |
1532 KB |
Output is correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
71 ms |
256 KB |
Output is correct |
10 |
Correct |
19 ms |
632 KB |
Output is correct |
11 |
Correct |
48 ms |
1236 KB |
Output is correct |
12 |
Correct |
44 ms |
1112 KB |
Output is correct |
13 |
Correct |
64 ms |
1612 KB |
Output is correct |
14 |
Correct |
41 ms |
1144 KB |
Output is correct |
15 |
Correct |
10 ms |
632 KB |
Output is correct |
16 |
Correct |
40 ms |
1144 KB |
Output is correct |
17 |
Correct |
107 ms |
2424 KB |
Output is correct |
18 |
Correct |
58 ms |
1532 KB |
Output is correct |
19 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |