結果
| 問題 |
No.781 円周上の格子点の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-18 14:12:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 938 bytes |
| コンパイル時間 | 1,799 ms |
| コンパイル使用メモリ | 175,832 KB |
| 実行使用メモリ | 336,328 KB |
| 最終ジャッジ日時 | 2024-10-01 14:01:24 |
| 合計ジャッジ時間 | 28,461 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
for (int i = 1; i <= sqrt(1e7); 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;
}