結果

問題 No.781 円周上の格子点の数え上げ
ユーザー WarToksWarToks
提出日時 2019-04-06 00:31:45
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 92,320 KB
実行使用メモリ 42,852 KB
最終ジャッジ日時 2023-08-20 12:19:12
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 98 ms
25,028 KB
testcase_13 AC 189 ms
42,852 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 99 ms
26,924 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>

constexpr int MAX_SIZE = 1e7+1;
int datum[MAX_SIZE] = {};

int main(void){
  int x, y, max = 0;scanf("%d %d", &x, &y);
  int i = 0, ii = 0, j, jj;
  while((ii = i * i) <= y){
  // ii * j * j >= x ~>
  const int edge = x - ii;
  j = floor(sqrt(x - ii));
  while((jj = j * j) < edge) j++;
    while((jj = j * j) <= y - ii){
      datum[ii + jj] += (i == 0 or j == 0) ? 2 : 4;
      j++;
    }
    i++;
  }
  for(int i = x; i <= y; i++) if(max < datum[i]) max = datum[i];
  printf("%d\n", max);
  return 0;
}
0