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 ...
随机推荐
- 何凯文每日一句打卡||DAY9
- python 基础部分重点复习整理--从意识那天开始进阶--已结
pythonic 风格编码 入门python好博客 进阶大纲 有趣的灵魂 老齐的教程 老齐还整理了很多精华 听说 fluent python + pro python 这两本书还不错! 元组三种遍历, ...
- python解析minicap
上篇知道了minicap发送图片的格式,照着官网的app.js代码,改用一个python版的来解析它,适当扩展,可以做个小工具实时显示手机屏幕. 步骤: 一.手机开启minicap服务 adb she ...
- [转载]Supporting OData $inlinecount with the new Web API OData preview package
http://www.strathweb.com/2012/08/supporting-odata-inlinecount-with-the-new-web-api-odata-preview-pac ...
- js和jquery使按钮失效为不可用状态的方法
设置disabled属性为true即为不可用状态. html代码: <input type="button" value="提交" id="bt ...
- XSS小游戏通关Writeup
源码下载:https://files.cnblogs.com/files/nul1/xss%E7%BB%83%E4%B9%A0%E5%B0%8F%E6%B8%B8%E6%88%8F.zip 我也没啥可 ...
- 【CTF WEB】命令执行
命令执行 找到题目中的KEY KEY为八位随机字符数字,例如key:1234qwer.提交1234qwer 即可. 漏洞代码 <?php system("ping -c 2 " ...
- WPF中各个Template的分析(转)
作为新手,还是没看明白本文,留着以后再学习 在使用TabControl.ListView.Menu.TreeView的时候被各种Template搞得头昏眼花,决心把这个问题搞清楚,究竟什么时候该用什么 ...
- SpringBoot 构建RestFul API 含单元测试
相关博文: 从消费者角度评估RestFul的意义 SpringBoot 构建RestFul API 含单元测试 首先,回顾并详细说明一下在快速入门中使用的 @Controller . @RestC ...
- VMware下centos桥接模式静态ip配置
声明:本文转载自http://blog.csdn.net/ltr15036900300/article/details/48828207,非原创. 一.配置虚拟机centos网络 备份网络文件 [ro ...