結果

問題 No.781 円周上の格子点の数え上げ
ユーザー beetbeet
提出日時 2019-01-11 21:46:25
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 2,158 ms
使用メモリ 81,264 KB
最終ジャッジ日時 2023-01-06 10:43:07
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 54 ms
81,196 KB
testcase_01 AC 54 ms
81,168 KB
testcase_02 AC 54 ms
81,192 KB
testcase_03 AC 52 ms
81,112 KB
testcase_04 AC 53 ms
81,096 KB
testcase_05 AC 53 ms
81,252 KB
testcase_06 AC 54 ms
81,180 KB
testcase_07 AC 54 ms
81,264 KB
testcase_08 AC 102 ms
81,088 KB
testcase_09 AC 103 ms
81,108 KB
testcase_10 AC 54 ms
81,216 KB
testcase_11 AC 54 ms
81,164 KB
testcase_12 AC 110 ms
81,256 KB
testcase_13 AC 114 ms
81,172 KB
testcase_14 AC 55 ms
81,164 KB
testcase_15 AC 53 ms
81,128 KB
testcase_16 AC 54 ms
81,188 KB
testcase_17 AC 97 ms
81,164 KB
testcase_18 AC 90 ms
81,184 KB
testcase_19 AC 92 ms
81,232 KB
testcase_20 AC 92 ms
81,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int x,y;
  cin>>x>>y;

  const Int MAX = 1e7+100;
  vector<Int> cnt(MAX,0);
 
  for(Int i=0;i*i<=y;i++){
    for(Int j=0;j<=i;j++){
      if(i*i+j*j>=MAX) continue;      
      cnt[i*i+j*j]++;
      if(j!=0&&i!=j) cnt[i*i+j*j]++;
    }
  }  

  Int ans=0;
  for(Int i=x;i<=y;i++) chmax(ans,cnt[i]*4);
  
  cout<<ans<<endl;
  return 0;
}
0