結果

問題 No.781 円周上の格子点の数え上げ
ユーザー MASATO338MASATO338
提出日時 2020-08-15 10:49:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 164,396 KB
実行使用メモリ 42,700 KB
最終ジャッジ日時 2023-08-01 01:00:42
合計ジャッジ時間 4,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
42,604 KB
testcase_01 AC 82 ms
42,464 KB
testcase_02 AC 83 ms
42,416 KB
testcase_03 AC 83 ms
42,420 KB
testcase_04 AC 78 ms
42,452 KB
testcase_05 AC 78 ms
42,700 KB
testcase_06 AC 78 ms
42,480 KB
testcase_07 AC 78 ms
42,444 KB
testcase_08 AC 79 ms
42,412 KB
testcase_09 AC 79 ms
42,472 KB
testcase_10 AC 79 ms
42,388 KB
testcase_11 AC 76 ms
42,388 KB
testcase_12 AC 90 ms
42,412 KB
testcase_13 AC 98 ms
42,428 KB
testcase_14 AC 77 ms
42,592 KB
testcase_15 AC 75 ms
42,376 KB
testcase_16 AC 77 ms
42,464 KB
testcase_17 AC 92 ms
42,528 KB
testcase_18 AC 77 ms
42,388 KB
testcase_19 AC 76 ms
42,412 KB
testcase_20 AC 80 ms
42,484 KB
権限があれば一括ダウンロードができます

ソースコード

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