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 ...
 
随机推荐
- 流媒体技术学习笔记之(九)减少VLC 延迟的方法
			
之前写过一篇关于在Linux平台上编译Android平台上VLC播放器源代码的文章,vlc这款播放器非常优秀而且是开源的,它的核心是开源视频编解码库ffmpeg.而且这款播放器还支持RTSP协议,这个 ...
 - 流媒体技术学习笔记之(八)海康、大华IpCamera RTSP地址和格式
			
海康: rtsp://[username]:[password]@[ip]:[port]/[codec]/[channel]/[subtype]/av_stream 说明: username: 用户名 ...
 - 工具类。父类(Pom文件)
			
ego_parent(pom文件) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...
 - 工作目录与os.getcwd()
			
假设某程序在/root/a/aa.py,在shell,当前pwd为/root,输入./a/aa.py运行py程序,则爱程序的工作目录是/root.而不是程序所在文件夹,os.getcwd()就是查看工 ...
 - 关联查询resultMap使用规则总结——(十一)
			
resultType: 作用: 将查询结果按照sql列名pojo属性名一致性映射到pojo中. 场合: 常见一些明细记录的展示,比如用户购买商品明细,将关联查询信息全部展示在页面时,此时可直接使用re ...
 - Twisted框架
			
Twisted是一个事件驱动型的网络模型.时间驱动模型编程是一种范式,这里程序的执行流由外部决定.特点是:包含一个事件循环,当外部事件发生时,使用回调机制来触发相应的处理. 线程模式: 1.单线程同步 ...
 - springcloud配置详解
			
Spring Boot的配置参考Spring Boot系列文章,这里只对Spring Cloud用到的配置解释. spring.application.name:配置应用名称,在注册中心中显示的服务注 ...
 - springcloud使用Hystrix实现微服务的容错处理
			
使用Hystrix实现微服务的容错处理 容错机制 如果服务提供者相应非常缓慢,那么消费者对提供者的请求就会被强制等待,知道提供者相应超时.在高负载场景下,如果不作任何处理,此类问题可能会导致服务消费者 ...
 - Entity Framework 6.1.0 Tools for Visual Studio 2012 & 2013
			
http://www.microsoft.com/en-us/download/confirmation.aspx?id=40762
 - Extjs Window用法详解 3 打印具体应用,是否关掉打印预览的界面
			
Extjs Window用法详解 3 打印具体应用,是否关掉打印预览的界面 Extjs 中的按钮元素 {xtype: 'buttongroup',title: '打印',items: [me.ts ...