D 题代码问
查看原帖
D 题代码问
1285950
4041nofoundGeoge楼主2025/1/18 21:58
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll r;
    cin >> r;
    auto in = [&](ll a, ll b) {
        return (2 * a + 1) * (2 * a + 1) + (2 * b + 1) * (2 * b + 1) <= 4 * r * r;
    };
    ll cnt = 0;
    ll up = r - 1;
    ll res = (r - 1) * 4 + 1;
    for(ll x = 1; in(x, 1); x++) {
        while(!in(x, up)) --up;
        cnt += up;
    }
    res += cnt * 4;
    cout << res << endl;
}

auto in = [&](ll a, ll b) { return (2 * a + 1) * (2 * a + 1) + (2 * b + 1) * (2 * b + 1) <= 4 * r * r; 是什么意思?

2025/1/18 21:58
加载中...