Problem Description
Lich Sandro investigates the magic of fire. He is standing in the center of a huge square hall with floor space one million square kilometers. The floor of the hall is paved with square 1 × 1 meter stone slabs. When Sandro waves his staff, a fire circle of radius R meters springs up around him. The center of the circle coincides with the center of the hall and is located at the point of contact of four slabs. Sandro wants to calculate the number of slabs damaged by the fire. A slab is assumed to be damaged if it has at least two common points with the fire circle. The figure shows as an example the slabs damaged by the fire circle of radius 4:
Input
The input file contains multiple cases. Proceed until End Of File.
Each case contains the radius of the fire circle R > 0. This is an integer not exceeding 105.
Output
Output the number of damaged slabs.
Sample Input
2
4
Sample Output
16
60
Hint:
Category: Geometry?
The max int value is about 2*10^9.
Such tip will never appear in formal Preliminary and Final games.
代码:
#include<iostream> #include<cmath> using namespace std; int main() { long long r; while(~scanf("%lld",&r)) { long long sum = 0; long long r1 = r*r; for(long long i=r-1;i>=0;i--) { long long r2 = r1-i*i; double len = sqrt((double)r2); sum+=(long long)ceil(len); } printf("%lld\n",sum*4); } }
相关推荐
BOJ的题目1023. Ancient Keyboard解法 源代码
boj 上08 09 年复试模拟题的答案
boj:算法
JAVA_BOJ
Algorithm-BOJ.zip,BekJon在线法官(Java,Kotlin,SWIFT)和PS路线图,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
BOJ
Algorithm-BOJ-PSJ.zip,Baykon在线判断JAVA问题解决方法(第二章),算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
Algorithm-BOJ-AutoCommit.zip,当您解决baekjoon online judge的问题时,它会自动提交并推送到远程存储库。,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
Algorithm-boj-auto-submit.zip,日本央行cli提交脚本,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
资源分类:Python库 所属语言:Python 资源全名:boj-0.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
通过这本图画书展示您的创造力,其中包括Boj和朋友。 一本有趣的,全数字化且可重复使用的着色书,可用于 通过这本图画书展示您的创造力,其中包括Boj和朋友。 一本有趣的全数字可重复使用的图画书,专为孩子,父母...
解决问题 Boj.kr
BOJ:日本央行
boj:算法求解