提出 #61833465


ソースコード 拡げる

#include <bits/stdc++.h>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for(int i = 0; (i) < (int)(n); ++(i))
#define rep_r(i, n) for(int i = (int)(n) - 1; (i) >= 0; --(i))
#define all(x) begin(x), end(x)

int main() {
    // input
    double R;
    cin >> R;

    // calc
    ll result;

    // 中央列の正方形の個数を計算
    result = (ll)floor(sqrt(R * R - 0.25) + 0.5) * 2 - 1;

    // 左右列の正方形の個数を計算
    for(int i = 1; i <= R - 0.5; i++) {
        ll add =
            ((ll)floorf64(sqrtf64(R * R - powf64(i + 0.5, 2)) + 0.5)) * 4 - 2;
        if(add < 0) break;
        result += add;
    }

    // output
    cout << result << endl;
}

提出情報

提出日時
問題 D - Squares in Circle
ユーザ Koreander
言語 C++ 23 (gcc 12.2)
得点 400
コード長 745 Byte
結果 AC
実行時間 22 ms
メモリ 3924 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 25
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3820 KiB
00_sample_01.txt AC 1 ms 3836 KiB
00_sample_02.txt AC 1 ms 3924 KiB
01_random_00.txt AC 6 ms 3808 KiB
01_random_01.txt AC 20 ms 3836 KiB
01_random_02.txt AC 10 ms 3864 KiB
01_random_03.txt AC 21 ms 3848 KiB
01_random_04.txt AC 14 ms 3880 KiB
01_random_05.txt AC 15 ms 3880 KiB
01_random_06.txt AC 20 ms 3860 KiB
01_random_07.txt AC 5 ms 3856 KiB
01_random_08.txt AC 15 ms 3720 KiB
01_random_09.txt AC 2 ms 3856 KiB
01_random_10.txt AC 21 ms 3848 KiB
01_random_11.txt AC 21 ms 3904 KiB
01_random_12.txt AC 21 ms 3756 KiB
01_random_13.txt AC 22 ms 3924 KiB
01_random_14.txt AC 21 ms 3852 KiB
01_random_15.txt AC 21 ms 3836 KiB
01_random_16.txt AC 21 ms 3864 KiB
01_random_17.txt AC 21 ms 3760 KiB
01_random_18.txt AC 21 ms 3924 KiB
01_random_19.txt AC 22 ms 3724 KiB
01_random_20.txt AC 1 ms 3668 KiB
01_random_21.txt AC 21 ms 3872 KiB