結果
問題 |
No.781 円周上の格子点の数え上げ
|
ユーザー |
|
提出日時 | 2020-04-13 14:37:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 816 bytes |
コンパイル時間 | 1,656 ms |
コンパイル使用メモリ | 170,628 KB |
実行使用メモリ | 42,388 KB |
最終ジャッジ日時 | 2024-09-24 23:11:17 |
合計ジャッジ時間 | 2,486 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; typedef long long ll; typedef pair<ll,ll> PL; typedef pair<int,int> P; const int INF = 1e9; const ll MOD = 1e9 + 7; const vector<int> dy = {-1,0,1,0}; const vector<int> dx = {0,1,0,-1}; int main() { int x,y; cin >> x >> y; vector<int> square; for (int i = 0;i * i <= y; i++) { square.push_back(i * i); } vector<int> cnt(y + 1,0); for (int p1:square) { for (int p2:square) { if (p1 + p2 < x || p1 + p2 > y) continue; if (p1 == 0 || p2 == 0) cnt[p1 + p2] += 2; else cnt[p1 + p2] += 4; } } int ans = 0; for (int i = x; i < y + 1; i ++) { ans = max(ans,cnt[i]); } cout << ans << endl; return 0; }