이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int, int>
#define pll pair<lli, lli>
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define test(x) cout << #x << ' ' << x << endl
#define printv(x) {\
for (auto a : x) cout << x << ' ';\
cout << endl;\
}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int N = 2000000;
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector <int> p;
for (int i = 1; i < n; ++i) if (n % i == 0) p.pb(i);
if (k == 0) {
lli ans = 1ll * n * n;
for (int i : p) {
ans = min(ans, 1ll * i * i * (1ll * (n / i) * (n / i) / 2));
}
cout << ans << endl;
return 0;
}
set <pii> s;
for (int i = 0, x1, y1, x2, y2; i < k; ++i) {
cin >> x1 >> y1 >> x2 >> y2, --x1, --y1;
s.insert({x1, y1});
}
lli ans = 1ll * n * n;
for (int i : p) {
lli cur = 1ll * i * i * (1ll * (n / i) * (n / i) / 2);
for (pii a : s) {
int x, y;
tie(x, y) = a;
x /= i, y /= i;
if ((x ^ y) & 1) {
cur--;
} else {
cur++;
}
}
ans = min({ans, cur, 1ll * n * n - cur});
}
cout << ans << endl;
}
/*
6 8
3 3 3 3
1 2 1 2
3 4 3 4
5 5 5 5
4 3 4 3
4 4 4 4
2 1 2 1
3 6 3 6
*/
# | 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... |