結果

問題 No.781 円周上の格子点の数え上げ
ユーザー karinohitokarinohito
提出日時 2024-04-08 10:50:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 3,411 ms
コンパイル使用メモリ 218,348 KB
実行使用メモリ 81,440 KB
最終ジャッジ日時 2024-04-08 10:50:33
合計ジャッジ時間 5,767 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 150 ms
81,440 KB
testcase_09 AC 133 ms
81,440 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 128 ms
81,440 KB
testcase_13 AC 133 ms
81,440 KB
testcase_14 AC 7 ms
7,752 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 79 ms
49,628 KB
testcase_18 AC 75 ms
49,628 KB
testcase_19 AC 80 ms
51,012 KB
testcase_20 AC 80 ms
51,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
template<class T>
bool chmax(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}
int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll X,Y;
    cin>>X>>Y;
    vll P(Y+1,0);
    ll an=0;
    for(ll x=1;x*x<=Y;x++){
        for(ll y=0;x*x+y*y<=Y;y++){
            P[x*x+y*y]+=4;
            if(x*x+y*y>=X)chmax(an,P[x*x+y*y]);
        }
    }
    cout<<an<<endl;
}
0