Submission #61814693


Source Code Expand

#include<bits/stdc++.h>
using namespace std; 
using i64 = long long;

void solve() {
    i64 R; cin >> R;
    auto ok = [&](i64 x, i64 h) -> bool {
        return (2 * x + 1) * (2 * x + 1) + (2 * h + 1) * (2 * h + 1) <= 4 * R * R;
    };
    i64 ans = 0;
    for (i64 x = 0; x < R; x++) {
        i64 low = 0, high = R + 1;
        while (low + 1 < high) {
            i64 m = (low + high) >> 1;
            if (ok(x, m)) {
                low = m;
            } else {
                high = m;
            }
        }
        if (x == 0) {
            ans += 4 * low + 1;
        }else {
            ans += 4 * low;
        }
    }
    cout << ans << '\n';
} 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    // cin >> tt;
    for(int t = 1; t <= tt; t++) {
        solve();
    }
}

Submission Info

Submission Time
Task D - Squares in Circle
User alpha1215
Language C++ 20 (gcc 12.2)
Score 400
Code Size 861 Byte
Status AC
Exec Time 41 ms
Memory 3628 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3592 KiB
00_sample_01.txt AC 1 ms 3504 KiB
00_sample_02.txt AC 1 ms 3452 KiB
01_random_00.txt AC 11 ms 3440 KiB
01_random_01.txt AC 37 ms 3452 KiB
01_random_02.txt AC 18 ms 3440 KiB
01_random_03.txt AC 40 ms 3452 KiB
01_random_04.txt AC 26 ms 3512 KiB
01_random_05.txt AC 28 ms 3512 KiB
01_random_06.txt AC 38 ms 3624 KiB
01_random_07.txt AC 8 ms 3508 KiB
01_random_08.txt AC 29 ms 3628 KiB
01_random_09.txt AC 3 ms 3388 KiB
01_random_10.txt AC 41 ms 3576 KiB
01_random_11.txt AC 41 ms 3580 KiB
01_random_12.txt AC 41 ms 3472 KiB
01_random_13.txt AC 40 ms 3444 KiB
01_random_14.txt AC 40 ms 3508 KiB
01_random_15.txt AC 41 ms 3508 KiB
01_random_16.txt AC 41 ms 3512 KiB
01_random_17.txt AC 41 ms 3508 KiB
01_random_18.txt AC 41 ms 3384 KiB
01_random_19.txt AC 41 ms 3380 KiB
01_random_20.txt AC 1 ms 3432 KiB
01_random_21.txt AC 41 ms 3404 KiB