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. [整理]Win下好用的Markdown工具

    用过haroopad,MarkPad,Sublime + markdown插件,前2款勉强能用,都处于继续开发中,haroopad支持的语法相对较少,提示也不明显,MarkPad还是有不少bug. 后 ...

  2. [python]文件操作read&readline&readlines

    (1)read是将整个文件读入内存,将整个文件的内容当作一个字符串 (2)readline是一行一行的读如内存,每一次读的一行为一个字符串 (3)readlines是一次将整个文件读入内存,但是将整个 ...

  3. Linux中Samba详细安装【转】

    转自:http://www.cnblogs.com/whiteyun/archive/2011/05/27/2059670.html 为了实现Windows主机与Linux服务器之间的资源共享,Lin ...

  4. 001_shell经典案例

    一. 二. -n, --numeric-sort compare according to string numerical value -k, --key=KEYDEF sort via a key ...

  5. net MongoDB安装

    Mongo服务器端下载链接:https://www.mongodb.com/download-center?jmp=nav 客户端查看工具Mongovue工具下载链接:http://pan.baidu ...

  6. Codeforces 671A Recycling Bottles(贪心+思维)

    题目链接:http://codeforces.com/problemset/problem/671/A 题目大意:给你两个人的位置和一个箱子的位置,然后给出n个瓶子的位置,要求让至少一个人去捡瓶子放到 ...

  7. MySQL的架构模型

    看到大牛用户DB架构部的Keithlan<数据库性能优化之查询优化>,在学习过程发现很多不错的东西,就把它保存下来,分享给大家,因为作者说了一句很经典的话:“if you want to ...

  8. T-SQL语句4

    一.插入数据 1.insert语句介绍 insert into table_name(column1,column2……column)values(value1,value2,……valueN)//c ...

  9. HNOI2019滚粗记

    HNOI2019滚粗记 标签: 游记 Day -1 在学校打摆被抓. Day 0 在家打摆. Day 1 来长沙理工大学打摆 开场看完题之后,感觉T3不太可做,然后T1T2又显得特别套路,然后把T2 ...

  10. NET定时任务组件Hangfire

    开源的.NET定时任务组件Hangfire解析 项目慢慢就要开工了,很多园友都在问这个事情,看来大伙对这事很上心啊,事情需要一步步的来,尽量写出一个我们都满意的项目.以前每次在博客前面都会扯淡一下,不 ...