結果
問題 |
No.781 円周上の格子点の数え上げ
|
ユーザー |
|
提出日時 | 2019-08-18 14:15:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 1,825 ms |
コンパイル使用メモリ | 177,744 KB |
実行使用メモリ | 337,824 KB |
最終ジャッジ日時 | 2024-10-01 13:59:10 |
合計ジャッジ時間 | 9,518 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 TLE * 1 -- * 8 |
ソースコード
typedef long long ll; #include <bits/stdc++.h> using namespace std; int main() { ll x,y; std::cin >> x>>y; // r = x^2 + y^2 // xが0からsqrt(r)までを確かめたら答えはでるが、TLE // 二乗足す二乗の和 // 10**3.5個ある // 0,1,4,9,16,,,10**7 // 前計算でありえる値を計算! // 既に二乗なら+4; vector<ll> sekilist; unordered_map<ll,ll> cou; ll sq = sqrt(y); for (int i = 1; i <= sq; i++) { sekilist.push_back(i*i); for (auto e : sekilist) { if( i*i != e ){ cou[i*i+e]+=8; }else{ cou[i*i+e]+=4; } } } ll result = -1; for (int i = x; i <= y; i++) { ll now = 0; if(i == (int)sqrt(i)*(int)sqrt(i)){ now+=4; } now += cou[i]; result = max(result,now); } std::cout << result << std::endl; }