hdu 3064 twoNumber
twoNumber
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 2048/1024 K (Java/Others)
Total Submission(s): 675 Accepted Submission(s): 210
这堆数字虽然杂乱无章,但是有一个特点,就是没有重复的数字,而且排序后可以首尾相连(不过丢失了两个);
由于数字可能会比较多,所以有一部分数字已经被合并压缩:
1 2 3 4 5
可以表示为数字段[1,5];
接下去输入两个数字,分别代表连续区间中最小的数字和最大的数字 (1<= st <= end <= 1000000),当然这个数字可能已经丢失。
接下去输入n行,每行输入2个数字(St,End)(1<= st <= end <= 1000000)。
St代表数字区间的开始,End代表数字区间的末尾。
数据保证缺少且仅缺少两个不相同的数字。
1 15
1 3
7 9
4 6
11 14
HINT: be careful with the memory limit;
= ans2-sum2;
#include "stdio.h"
#include "math.h" int main()
{
int n;
__int64 x,y;
__int64 ans1,ans2;
__int64 sum1,sum2;
__int64 t1,t2;
__int64 a,b;
__int64 deta;
while(scanf("%d",&n)!=-)
{
ans1 = ans2 = ;
sum1 = sum2 = ;
scanf("%I64d %I64d",&x,&y);
ans1 = (x+y)*(y-x+)/;
t1 = x*(x-)*(*x-)/;
t2 = y*(y+)*(*y+)/;
ans2 = t2-t1; while(n--)
{
scanf("%I64d %I64d",&x,&y); sum1 += (x+y)*(y-x+)/; t1 = x*(x-)*(*x-)/;
t2 = y*(y+)*(*y+)/;
sum2 += t2-t1;
}
ans1 -= sum1;
ans2 -= sum2;
a = ans1;
b = ans2;
deta = (__int64)sqrt((double)(*b-a*a));
x = (a-deta)/;
y = a - x;
printf("%I64d %I64d\n",x,y);
}
return ;
}
hdu 3064 twoNumber的更多相关文章
- hdu 3064
1:前n项和公式:1+2+3+...+n = n*(n+1)/2 2:前n项平方和公式:1^2+2^2+.........+n^2=n*(n+1)*(2n+1)/6 #include<stdio ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- SQL查询作业执行情况
查询作业的执行情况sql: SELECT [JobName] = JOB.name, [Step] = HIST.step_id, [StepName] = HIST.step_name, [Mess ...
- IIS启动网站出错的几个解决方法
在ASP.NET项目中使用了IIS服务器,由于系统是XP的,而在装系统的时候IIS没有一起装,所以从网上下载的IIS5.0版本(其它版本XP是用不了的).但是在使用的过程中老是出问题,每次调试好后,过 ...
- C#调用windows api示例
这是运行结果: Api函数是构筑Windws应用程序的基石,每一种Windows应用程序开发工具,它提 供的底层函数都间接或直接地调用了Windows API函数,同时为了实现功能扩 展,一般也都提供 ...
- Interlocked.CompareExchange
class SourceManager { private SourceManager() { } private static SourceManager sourceManager; public ...
- Windows nexus 启动失败
现象: nexus Windows系统服务安装成功,但启动失败 D:\nexus-2.10.0-02-bundle\nexus-2.10.0-02\bin>nexus.bat Usage: ne ...
- java开发过程中从前台传到后台中文乱码《filter》
在企业开发中,最常见的是javaweb项目,有web项目就免不了和后台打交道,比如我从jsp页面发送新增请求到后台,后台可能是servlet.struts2.springmvc等,这时就存在一个问题, ...
- 【iOS】Quartz2D基本图形
一.画线段 - (void)drawRect:(CGRect)rect { // Drawing code // 1.获得图形上下文 CGContextRef ctx = UIGraphicsGetC ...
- iOS 七牛云上传并获取图片----【客户端】
最近做了七牛云存储的有关内容,涉及到与后台交互获取验证的token,无奈,后台自命清高,不与理会,没办法呀,于是自己搞呗.首先呢在在七牛上注册一个账号,然后呢添加一个存储空间这时候空间名 ...
- RadioButton 自定义控件
在res/drawable新建radiobutton.xml(本案例为video——evaluate.xml)如下 <?xml version="1.0" encoding= ...
- 从网络中获取图片显示到Image控件并保存到磁盘
一.从网络中获取图片信息: /// <summary> /// 获取图片 /// </summary> /// <param name="url"&g ...