結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,715 ms
444,004 KB
testcase_01 AC 1,676 ms
113,076 KB
testcase_02 AC 1,673 ms
113,080 KB
testcase_03 AC 1,716 ms
113,112 KB
testcase_04 AC 1,699 ms
112,952 KB
testcase_05 AC 1,711 ms
112,912 KB
testcase_06 AC 1,676 ms
113,084 KB
testcase_07 AC 1,674 ms
113,084 KB
testcase_08 AC 1,700 ms
113,080 KB
testcase_09 AC 1,683 ms
112,956 KB
testcase_10 AC 1,706 ms
113,464 KB
testcase_11 AC 1,691 ms
114,228 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(1e7); 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