Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem I. Alien Rectangles 数学
Problem I. Alien Rectangles
题目连接:
http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&all_runs=1&action=140
Description
The spacecraft hovering above the surface of the faraway planet takes pictures of the landscape underneath
from time to time. Each photo is a circle centred at the point the spacecraft is orbiting over.
For detailed study of the planet’s surface researchers have chosen a Cartesian coordinate system on the
photos with the origin placed to the circle’s centre. The radius of the circle is R. The following stage of
the research requires selecting a region in the form of a nondegenerate rectangle with sides parallel to the
coordinate axes and with vertices at the points with integer coordinates. The points should lie inside or
on the boundary of the circle.
Please help the researchers and compute the total number of ways to choose a rectangular region. As the
number of ways may be big, output it modulo 109 + 2015.
Input
Input contains the only integer R (1 ≤ R ≤ 1 000 000).
Output
Output the only integer: the number of ways to choose a rectangle in the given circle modulo 109 + 2015.
Sample Input
2
Sample Output
9
Hint
题意
有一个中心在原点的圆,然后半径为R,问你里面以及圆上的整点,能够成多少个矩形。
题解:
算出每个坐标的点的个数,然后开始推公式就好了。
具体看代码。
至于看到只有一个数,就去推O1公式的,基本就走远了……
代码
#include <bits/stdc++.h>
using namespace std;
const int N=1000100;
const int pr=1e9 + 2015;
long long ans=0;
int main()
{
int R;
scanf("%d",&R);
int nx=1;
for(int i=1;i<=R;i++)
{
int x=i*2+1;
int y=(int)sqrt(1LL*R*R-1LL*i*i)*2+1;
long long t1,t2;
t1=1LL*x*(x-1)/2LL,t2=1LL*y*(y-1)/2LL;
if(t1>=pr) t1%=pr;
if(t2>=pr) t2%=pr;
ans+=(t1*t2%pr);
if(ans>=pr) ans%=pr;
t1=1LL*nx*(nx-1)/2LL,t2=1LL*y*(y-1)/2LL;
if(t1>=pr) t1%=pr;
if(t2>=pr) t2%=pr;
ans-=(t1*t2%pr);
if(ans<0) ans+=pr;
nx=x;
}
cout<<ans<<endl;
}
Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem I. Alien Rectangles 数学的更多相关文章
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题
Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem H. Parallel Worlds 计算几何
Problem H. Parallel Worlds 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力
Problem F. Turning Grille 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c70 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem C. Cargo Transportation 暴力
Problem C. Cargo Transportation 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem G. k-palindrome dp
Problem G. k-palindrome 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022 ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem A. A + B
Problem A. A + B 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&al ...
- 2010 NEERC Western subregional
2010 NEERC Western subregional Problem A. Area and Circumference 题目描述:给定平面上的\(n\)个矩形,求出面积与周长比的最大值. s ...
- 2009-2010 ACM-ICPC, NEERC, Western Subregional Contest
2009-2010 ACM-ICPC, NEERC, Western Subregional Contest 排名 A B C D E F G H I J K L X 1 0 1 1 1 0 1 X ...
- 【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest
A-Area and Circumference 题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值. #include <iostream> #include <algo ...
随机推荐
- 【转载】RESTful API 设计指南
作者: 阮一峰 日期: 2014年5月22日 网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板.桌面电脑.其他专用设备......). 因此,必须有一种统一的机制 ...
- HDU 1176 免费馅饼 DP类似数塔题
解题报告: 小明走在一条小路上,这条小路的长度是10米,从左到右依次是0到10一共十个点,现在天上会掉馅饼,给出馅饼掉落的坐标和时间,一开始小明的位置是在坐标为5的位置, 他每秒钟只能移动一米的距离, ...
- 第7月第20天 epoll
1. ) { struct sockaddr in_addr; socklen_t in_len; int infd; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; ...
- spm
Spatial Pyramid Matching 看了很多关于SPM的介绍,但是网络上的资源大多都是对论文Beyond bags of features: Spatial pyramid matchi ...
- Java内存模型-锁的内存语义
一 引言 在说volatile的内存语义时,讲过这样一句话:想要理解透volatile特性有一个很好的方法,就是把对volatile变量的单个读/写,看成是使用同一个锁对这些单个读/写操作做了同步.所 ...
- Heapify
Given an integer array, heapify it into a min-heap array. For a heap array A, A[0] is the root of he ...
- [转]使用 mitmproxy + python 做拦截代理
使用 mitmproxy + python 做拦截代理 本文是一个较为完整的 mitmproxy 教程,侧重于介绍如何开发拦截脚本,帮助读者能够快速得到一个自定义的代理工具. 本文假设读者有基本的 ...
- ipsec-tools安装教程
ipsec-tools最新版本为0.8.2,此处以0.7.3版本为例说明安装和使用过程.可参考ipsec-howto. 安装步骤 ipsec-tools依赖于linux2.6版本内核,在安装ipsec ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法
更换mysql数据目录后出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql ...
- selnium远程机上传图片遇到的坑
一般上传图片方法采取方案如下: input标签的file类型上传图片,使用对象的sendkeys+路径方法 使用js注入,再用使用对象的sendkeys+路径方法 使用autolt生成的exe,打开对 ...