結果

問題 No.781 円周上の格子点の数え上げ
ユーザー rlangevinrlangevin
提出日時 2023-01-12 22:42:38
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,864 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 5,988 ms
コンパイル使用メモリ 310,952 KB
実行使用メモリ 88,172 KB
最終ジャッジ日時 2023-08-25 03:08:09
合計ジャッジ時間 10,199 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 7 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 839 ms
47,744 KB
testcase_13 AC 1,864 ms
88,172 KB
testcase_14 AC 7 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1,038 ms
51,788 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using mint = modint998244353;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int X, Y;
    cin >> X >> Y;
    int i = 1;
    unordered_map<int, int> mp;
    vector<int> L;
    while (i * i <= Y)
    {
        L.push_back(i * i);
        mp[i * i] += 1;
        i += 1;
    }
    int N = L.size();
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            int a = L[i];
            int b = L[j];
            if (a == b)
            {
                if (X <= a + b && a + b <= Y)
                {
                    mp[a + b] += 1;
                }
            }
            else{
                if (X <= a + b && a + b <= Y)
                {
                    mp[a + b] += 2;
                }
            }
        }
    }

    int ans = 0;
    for (P p : mp)
    {
        int k = p.first;
        int v = p.second;
        if (X <= k && k <= Y)
        {
            ans = max(ans, v);
        }
    }
    cout << ans * 4 << endl;
}
0