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 数学的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 2010 NEERC Western subregional

    2010 NEERC Western subregional Problem A. Area and Circumference 题目描述:给定平面上的\(n\)个矩形,求出面积与周长比的最大值. s ...

  8. 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 ...

  9. 【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest

    A-Area and Circumference 题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值. #include <iostream> #include <algo ...

随机推荐

  1. [转载]VS2013 密钥 – 所有版本

    http://www.wxzzz.com/307.html Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visu ...

  2. [整]Android开发优化-布局优化

    优化布局层次结构 一个普遍的误解就是,使用基本的布局结构会产生高效的布局性能.然而每一个添加到应用的控件和布局,都需要初始化,布局位置和绘制.比如,使用一个嵌套的LinearLayout会导致过深的布 ...

  3. [BZOJ 2257][JSOI2009]瓶子和燃料 题解(GCD)

    [BZOJ 2257][JSOI2009]瓶子和燃料 Description jyy就一直想着尽快回地球,可惜他飞船的燃料不够了. 有一天他又去向火星人要燃料,这次火星人答应了,要jyy用飞船上的瓶子 ...

  4. python的__get__、__set__、__delete__(1)

    内容:    描述符引导        摘要        定义和介绍        描述符协议        调用描述符        样例        Properties        函数和 ...

  5. CentOS7 关闭防火墙和selinux

    本文将简单介绍在CentOS7上如何临时和永久关闭防火墙和selinux. 关闭防火墙 # 查看防火墙状态 [root@localhost ~]# systemctl status firewalld ...

  6. C# 文件Copy

    文件Copy有以下几种方法: 1.Copy string sourceFile = @"c:\temp\New Text Document.txt"; string destina ...

  7. 转:Citrix虚拟化--转自CSDN

    http://blog.csdn.net/kkfloat/article/category/1430751/3

  8. AtomicInteger源码

    一.概念 AtomicInteger,一个提供原子操作的Integer的类.在Java语言中,++i和i++操作并不是线程安全的,在使用的时候,不可避免的会用到synchronized关键字.而Ato ...

  9. Project Euler Problem1

    Multiples of 3 and 5 Problem 1 If we list all the natural numbers below 10 that are multiples of 3 o ...

  10. 部分Web服务器信息对比

    本文参考wikipedia的Web服务器比较页面的数据,选取了其中自己感兴趣的Web服务器的信息进行了对比,包括,Apache HTTP Server.Apache Tomcat.Nginx.Catt ...