結果
| 問題 | No.781 円周上の格子点の数え上げ | 
| コンテスト | |
| ユーザー |  siman | 
| 提出日時 | 2021-07-01 20:32:52 | 
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 134 ms / 2,000 ms | 
| コード長 | 1,029 bytes | 
| コンパイル時間 | 2,761 ms | 
| コンパイル使用メモリ | 141,072 KB | 
| 実行使用メモリ | 42,524 KB | 
| 最終ジャッジ日時 | 2024-06-28 09:52:21 | 
| 合計ジャッジ時間 | 3,858 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 21 | 
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
const int MAX_V = 10010000;
int counter[MAX_V];
int main() {
  int X, Y;
  cin >> X >> Y;
  int S, L;
  S = ceil(sqrt(X));
  if (X == Y) {
    L = S;
  } else {
    L = ceil(sqrt(Y));
  }
  assert(MAX_V > L * L);
  for (int x = 0; x <= L * L; ++x) {
    counter[x] = 0;
  }
  for (int x = S; x <= L; ++x) {
    int v = x * x;
    if (v < X) continue;
    if (v > Y) continue;
    counter[v] += 1;
  }
  for (int y = 0; y < L; ++y) {
    int dy = y * y;
    for (int x = 0; x < L; ++x) {
      int dx = x * x;
      int v = dy + dx;
      if (v < X) continue;
      if (v > Y) continue;
      counter[v] += 1;
    }
  }
  int ans = 0;
  for (int x = 0; x <= L * L; ++x) {
    int value = counter[x];
    ans = max(ans, value);
  }
  cout << 4 * ans << endl;
  return 0;
}
            
            
            
        