結果

問題 No.781 円周上の格子点の数え上げ
ユーザー どららどらら
提出日時 2019-01-11 22:18:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 166,944 KB
実行使用メモリ 42,704 KB
最終ジャッジ日時 2023-08-20 07:34:06
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
42,456 KB
testcase_01 AC 197 ms
42,484 KB
testcase_02 AC 194 ms
42,704 KB
testcase_03 AC 193 ms
42,472 KB
testcase_04 AC 197 ms
42,660 KB
testcase_05 AC 192 ms
42,484 KB
testcase_06 AC 191 ms
42,452 KB
testcase_07 AC 184 ms
42,456 KB
testcase_08 AC 191 ms
42,596 KB
testcase_09 AC 202 ms
42,492 KB
testcase_10 AC 191 ms
42,456 KB
testcase_11 AC 192 ms
42,528 KB
testcase_12 AC 195 ms
42,464 KB
testcase_13 AC 201 ms
42,508 KB
testcase_14 AC 193 ms
42,512 KB
testcase_15 AC 206 ms
42,540 KB
testcase_16 AC 204 ms
42,528 KB
testcase_17 AC 211 ms
42,452 KB
testcase_18 AC 196 ms
42,468 KB
testcase_19 AC 204 ms
42,544 KB
testcase_20 AC 198 ms
42,552 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