結果

問題 No.781 円周上の格子点の数え上げ
ユーザー どららどらら
提出日時 2019-01-11 22:18:02
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 1,360 ms
使用メモリ 42,648 KB
最終ジャッジ日時 2023-01-06 13:35:32
合計ジャッジ時間 5,807 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 150 ms
42,500 KB
testcase_01 AC 146 ms
42,552 KB
testcase_02 AC 150 ms
42,564 KB
testcase_03 AC 155 ms
42,560 KB
testcase_04 AC 149 ms
42,544 KB
testcase_05 AC 150 ms
42,604 KB
testcase_06 AC 146 ms
42,604 KB
testcase_07 AC 150 ms
42,544 KB
testcase_08 AC 145 ms
42,548 KB
testcase_09 AC 149 ms
42,560 KB
testcase_10 AC 141 ms
42,496 KB
testcase_11 AC 151 ms
42,544 KB
testcase_12 AC 150 ms
42,500 KB
testcase_13 AC 154 ms
42,640 KB
testcase_14 AC 142 ms
42,496 KB
testcase_15 AC 143 ms
42,548 KB
testcase_16 AC 140 ms
42,560 KB
testcase_17 AC 154 ms
42,544 KB
testcase_18 AC 144 ms
42,544 KB
testcase_19 AC 151 ms
42,504 KB
testcase_20 AC 145 ms
42,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const int MAXN = 10000005;
int cnt[MAXN];

int main(){
  int X, Y;
  cin >> X >> Y;

  vector<ll> v;
  ll p = 0;
  while(p*p < MAXN){
    v.push_back(p*p);
    p++;
  }

  rep(i,v.size()){
    rep(j,v.size()){
      int val = v[i] + v[j];
      if(val < MAXN){
        if(v[i] == 0 || v[j] == 0) cnt[val] += 2;
        else cnt[val] += 4;
      }
    }
  }
  
  int ret = 0;
  REP(i,X,Y+1){
    ret = max(ret, cnt[i]);
  }

  cout << ret << endl;
  
  return 0;
}
0