CodeForces 78D Archer's Shot
二分。
统计过程如下图:
先统计红线上的个数,然后统计绿线上的个数,然后统计咖啡色线上的个数......一个一个往下统计就可以了。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar();
x = ;
while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} double r;
double sqrt3=sqrt(3.0); double dis(double x,double y) { return x*x+y*y; } bool check(double x,double y)
{
if(dis(x,y+)-eps>r*r) return ;
if(dis(x,y-)-eps>r*r) return ;
if(dis(x+sqrt3/,y+0.5)-eps>r*r) return ;
if(dis(x+sqrt3/,y-0.5)-eps>r*r) return ;
if(dis(x-sqrt3/,y+0.5)-eps>r*r) return ;
if(dis(x-sqrt3/,y-0.5)-eps>r*r) return ;
return ;
} int main()
{
while(~scanf("%lf",&r))
{
LL ans=, L=,R=(LL),pos;
while(L<=R)
{
LL mid=(L+R)/;
if(check((mid-)*sqrt3,)) pos=mid, L=mid+;
else R=mid-;
}
LL cnt=; double x=,y=-;
while()
{
if(!check(x,y)) break;
LL L=,R=(LL),pp;
while(L<=R)
{
LL mid=(L+R)/;
if(check(x-(mid-)*sqrt3/,y-(mid-)*1.5)) pp=mid, L=mid+;
else R=mid-;
}
pp=+(pp-)*, cnt=cnt+pp, y=y-;
}
ans=*(pos-)++*cnt;
printf("%lld\n",ans);
}
return ;
}
CodeForces 78D Archer's Shot的更多相关文章
- CodeForces 312B Archer
Archer Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ...
- hdu 5318 The Goddess Of The Moon
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- HDU 5318——The Goddess Of The Moon——————【矩阵快速幂】
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- 2015 Multi-University Training Contest 3 hdu 5318 The Goddess Of The Moon
The Goddess Of The Moon Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- hdu 5318 The Goddess Of The Moon 矩阵高速幂
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5318 The Goddess Of The Moon Time Limit: 6000/3000 MS ( ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #330 (Div. 1) A. Warrior and Archer 贪心 数学
A. Warrior and Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594 ...
- 【CodeForces 312B】BUPT 2015 newbie practice #3A Archer
题 SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the targ ...
- Codeforces 595C - Warrior and Archer
595C - Warrior and Archer 思路:设最后答案的区间为[l,r],那么r-l等于n/2,因为在(l,r)中的点都是其中一个人挖掉的,[0,l)和(r,n]中的点是另一个人挖掉的, ...
随机推荐
- 第一章 CLR 的执行模型
CLR via C# 读书笔记:第一章 CLR 的执行模型(1) 第Ⅰ部分CLR基础.这部分为三章(第一章:CLR的只想能够模型,第二章:生成.打包.部署和管理应用程序及类型,第三章:共享程序集和强命 ...
- 利用Bootstrap框架制作查询页面的界面
UI设计实战篇——利用Bootstrap框架制作查询页面的界面 Bootstrap框架是一个前端UI设计的框架,它提供了统一的UI界面,简化了设计界面UI的过程(缺点是定制了界面,调整的余地不是太 ...
- ajaxFileUpload+struts2实现多文件上传(动态添加文件上传框)
上篇文章http://blog.csdn.net/itmyhome1990/article/details/36396291介绍了ajaxfileupload实现多文件上传, 但只是固定的文件个数,如 ...
- Mathematics for Computer Graphics
Mathematics for Computer Graphics 最近严重感觉到数学知识的不足! http://bbs.gameres.com/showthread.asp?threadid=105 ...
- Android Jni引用第三方库
在jni下新建文件夹(jniLib)用来存放第三方so库: 将so拷贝到jniLib下,新建一个Android.mk文件: LOCAL_PATH:= $(call my-dir) include $( ...
- dotfiles for linux/unix users automatically! (python Vim IDE)
Here is a brief introduction and package of dotfiles for linux/unix user. I think there are enough i ...
- 【Linux】CentOS 学习笔记之二(命令)
打开文件夹: cd finename 创建目录:mkdir /filename mkdir -p /test/123/111 (多级目录) 删除目录: rmdir 删除目录或文件: r ...
- Unable to start T-SQL Debugging. Could not connect to the computer ‘.’
Unable to start T-SQL Debugging. Could not connect to the computer ‘.’ 在Win7上面使用SSMS连接到SQL Server使用D ...
- lua读书笔记
接下来把我所看的<Lua程序设计>中介绍lua的内容,时时的记录下来.当做一个读书笔记吧. 先说一下怎样直接运行lua文件吧,windows cmd进入相应的文件夹,然后输入lua,出现版 ...
- Js-Html 前端系列--点击非Div区域隐藏Div
最近做项目要用到三字码下拉,调用一个插件,但是滚动条不能点击. 后来看另一个插件后突发奇想,在点击其他区域的时候隐藏这个Div就可以了. 背景:输入文字,弹出下拉Div,点击或者拉动Div滚动条选择, ...