結果

問題 No.781 円周上の格子点の数え上げ
ユーザー kappybar
提出日時 2020-04-13 14:41:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 172,072 KB
実行使用メモリ 81,576 KB
最終ジャッジ日時 2024-09-24 23:17:40
合計ジャッジ時間 4,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const ll INF = 1e18;
const int MOD = 1000000007;

int main(){
    int x,y;
    cin >> x >> y;
    vector<int> square;
    vector<ll> cnt(y+1,0);
    for(int i=0;i*i<=y;i++){
        if(i==0) square.push_back(i * i);
        else{
            square.push_back(i * i);
            square.push_back(i * i);
        }
    }

    rep(i,square.size()){
        rep(j,square.size()){
            if(square[i]+square[j] > y) continue;
            cnt[square[i]+square[j]] ++;
        }
    }

    ll ans = 0;
    for(int i=x;i<=y;i++){
        ans = max(ans,cnt[i]);
    }
    cout << ans << endl;
    return 0;
}
0