結果

問題 No.781 円周上の格子点の数え上げ
ユーザー erbowlerbowl
提出日時 2019-08-18 14:33:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,460 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 173,480 KB
実行使用メモリ 229,224 KB
最終ジャッジ日時 2024-04-09 02:12:27
合計ジャッジ時間 8,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,944 KB
testcase_05 WA -
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 8 ms
6,948 KB
testcase_08 AC 1,417 ms
112,948 KB
testcase_09 AC 1,415 ms
112,952 KB
testcase_10 WA -
testcase_11 WA -
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;
    
    ll sq = sqrt(y);
    
    
    for (int i = 1; i <= sq; 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;
    vector<ll> can = { 0, 1, 4, 9, 16, 17, 25, 33, 36, 41, 49, 57, 64, 65, 68, 73, 81, 89, 97, 100, 105, 113, 121, 129, 132, 137, 144, 145, 153, 161, 164, 169, 177, 185, 193, 196, 201, 209, 217, 225, 228, 233, 241, 249 };
    for (int i = x; i <= y; i++) {
        ll now = 0;
        ll m=i%256;
        bool able = false;
        for (auto e : can) {
            if(m == e){
                able = true;
                break;
            }
        }
        if(able){
            std::cout <<  i<< std::endl;
            ll ssq =  (int)sqrt(i);
            if(i == ssq*ssq){
                now+=4;
            }
        }

        now += cou[i];
        result = max(result,now);
    }
    std::cout << result << std::endl;
    
}
0