#P1676. 「CMOI R0」Parallel Universe Shifter / Lattices in Circle

「CMOI R0」Parallel Universe Shifter / Lattices in Circle

背景

原《[USACO05FEB] Aggressive Cows G》参见 P1824。

$$\text{Answer}=\pi n^2+\mathrm O(n^{\frac{517}{824}}).$$

$\small\color{white}/35^{\text{th}}\text{Problem by AtC}.$

题目描述

求与原点距离不超过 n(1≤n≤1012)n(1\leq n\leq 10^{12}) 的整点个数。

输入格式

一行一个正整数 nn。

输出格式

一行一个正整数,即答案。注意它可能大于 2642^{64}。

1
5
2
13
5
81
19
1129
100
31417
30000
2827432965
10000000
314159265350589
500000000
785398163397389961
16000000000
804247719318986163169
700000000000
1539380400258998682200449

提示

样例 11 解释

符合条件的 55 个点是 (0,0),(1,0),(0,1),(0,−1),(−1,0)(0,0),(1,0),(0,1),(0,-1),(-1,0)。

数据范围

Subtask\text{Subtask} Special Constraints\text{Special Constraints} Time Limit\text{Time Limit} Points\text{Points}
11 1≤n≤2×1031\leq n\leq 2\times 10^3 0.25s0.25\text s 11
22 104≤n≤10710^4\leq n\leq 10^7 1s1\text s 44
33 108≤n≤10910^8\leq n\leq 10^9 1010
44 109≤n≤101010^9\leq n\leq 10^{10} 3s3\text s 1515
55 1010≤n≤101110^{10}\leq n\leq 10^{11} 4s4\text s 3030
66 1011≤n≤101210^{11}\leq n\leq 10^{12} 4040