Submission #518737

# Submission time Handle Problem Language Result Execution time Memory
518737 2022-01-24T14:09:34 Z spike1236 Chessboard (IZhO18_chessboard) C++14
8 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 1e5 + 10;
int n, k;
ll cnt[MAXN];
veci dv;

int get(int r, int k) {
    int nr = (r % k == 0 ? r : r - r % k);
    int bl = nr / k;
    int cnt = (bl + 1) / 2 * k;
    if(bl % 2 == 0) cnt += r - nr;
    return cnt;
}

void solve() {
    cin >> n >> k;
    dv.pb(1);
    for(int i = 2; i * i <= n; ++i) {
        if(n % i == 0) {
            dv.pb(i);
            if(i * i != n) dv.pb(n / i);
        }
    }
    sort(all(dv));
    ll ans = 1e18;
    for(auto i : dv) {
        ll cnt1 = get(n, i);
        cnt[i] = cnt1 * i * (((n / i) + 1) / 2) + (n - cnt1) * i * (n / i - (((n / i) + 1) / 2));
        ans = min(ans, min(cnt[i], n * 1ll * n - cnt[i]));
    }
    cout << ans;
    /**for(int rect = 1; rect <= k; ++rect) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        for(auto i : dv) {

        }
    }**/
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int CNT_TESTS = 1;
    ///cin >> CNT_TESTS;
    for(int NUMCASE = 1; NUMCASE <= CNT_TESTS; ++NUMCASE) {
        solve();
        if(NUMCASE != CNT_TESTS) cout << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -