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 ...
随机推荐
- 快速幂 --- CSU 1556: Jerry's trouble
Jerry's trouble Problem's Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1556 Mean: 略. ana ...
- c++转C#
//c++:HANDLE(void *) ---- c#:System.IntPtr //c++:Byte(unsigned char) ---- ...
- oracle中文显示为问号
在用PL/sql查询时,中文显示为问号.经查证,发现问题为oracle字符集不支持中文导致的.修改oracle字符集,改为支持中文即可. 方法: 第一步:修改注册表. 开始-运行-输入regedit- ...
- JS+JQ手风琴效果
最新在学习JS写一些实用的小玩意——手风琴 CSS样式: <style type="text/css"> * { margin: 0px; border: 0px; p ...
- php5.6-Apache2.4-mysql5.6环境配置(win7_64位)
----------------------------------------------------- ★软件工具:(下载时注意下载相应版本,不同版本安装细节可能会有差异!!) 1>http ...
- #define lowbit(x) ((x)&(-x))原理详解
#define lowbit(x) ((x)&(-x)) 也可以写成如下形式: int Lowbit(x) { return x&(-x); } 例如: 1> x = 1: 十进 ...
- 使用svcutil.exe 工具来生成调用文件
svcutil.exe http://localhost:9065/ServiceDemo.svc?wsdl 这将生成一个配置文件和一个包含客户端类的代码文件. 下面我们就用这个是怎么生成的: 1,打 ...
- 微信公共平台开发2 .net
成功的走出第一步后,我们紧接着趁热打铁开始下一步: 成为了开发者之后微信平台会给您AppId和AppSecret,在订阅号中是没有的,所以因该申请一下服务号, 若没有请注意上一篇http://www. ...
- Vue自带的过滤器
gitHub地址:https://github.com/lily1010/vue_learn/tree/master/lesson05 一 过滤器写法 {{ message | Filter}} 二 ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q100-Q103)
Question 100You create a Web Part.You need to display the number of visits to a SharePoint site coll ...