結果

問題 No.781 円周上の格子点の数え上げ
ユーザー erbowlerbowl
提出日時 2019-08-18 14:14:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 936 bytes
コンパイル時間 5,147 ms
コンパイル使用メモリ 172,976 KB
実行使用メモリ 338,004 KB
最終ジャッジ日時 2024-04-09 02:10:45
合計ジャッジ時間 10,147 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,764 KB
testcase_01 AC 1 ms
6,948 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 8 ms
6,944 KB
testcase_08 AC 1,523 ms
112,956 KB
testcase_09 AC 1,493 ms
113,080 KB
testcase_10 AC 5 ms
6,948 KB
testcase_11 AC 10 ms
6,952 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    ll x,y;
    std::cin >> x>>y;
    // r = x^2 + y^2
    // xが0からsqrt(r)までを確かめたら答えはでるが、TLE
    // 二乗足す二乗の和
    // 10**3.5個ある
    // 0,1,4,9,16,,,10**7
    // 前計算でありえる値を計算!
    // 既に二乗なら+4;
    vector<ll> sekilist;
    unordered_map<ll,ll> cou;
    
    for (int i = 1; i <= sqrt(y); i++) {
        sekilist.push_back(i*i);
        for (auto e : sekilist) {
            if( i*i != e ){
                cou[i*i+e]+=8;
            }else{
                cou[i*i+e]+=4;
            }
        }
    }
    ll result = -1;
    for (int i = x; i <= y; i++) {
        ll now = 0;
        if(i == (int)sqrt(i)*(int)sqrt(i)){
            now+=4;
        }
        now += cou[i];
        result = max(result,now);
    }
    std::cout << result << std::endl;
    
}
0