結果

問題 No.781 円周上の格子点の数え上げ
ユーザー MASATO338
提出日時 2020-08-15 10:49:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 1,707 ms
コンパイル使用メモリ 166,728 KB
実行使用メモリ 42,584 KB
最終ジャッジ日時 2024-10-10 17:25:31
合計ジャッジ時間 4,811 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int cnt[10000001] = {0};
int main(){
  ll x,y;
  cin>>x>>y;
  for(int i(0);i<4000;i++){
    for(int j(0);j<4000;j++){
      ll x = i*i+j*j;
      if(x <= 10000000){
        cnt[x]++;
      }
    }
  }
  int ans(0);
  for(int i(x);i<=y;i++){
    if((int)sqrt(i)*(int)sqrt(i) == i) ans = max(ans,(cnt[i]-1)*4);
    else ans = max(ans,cnt[i]*4);
  }
  cout << ans << endl;
  return 0;
}

0