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 ...
随机推荐
- error LNK1281: 无法生成 SAFESEH 映像 LNK2026 模块对于 SAFESEH 映像是不安全的 VS2015 /win10
平台 VS2015 /win10 错误 LNK1281 无法生成 SAFESEH 映像. 错误 LNK2026 模块对于 SAFESEH 映像是不安全的. 将 release 改成 debug
- web api返回格式小结
web api返回格式小结: 1.默认是返回xml格式数据,如果需要返回json格式,需要在Global.asax中加入: GlobalConfiguration.Configuration.Form ...
- DataSet导出到Excel,并生成文件(C#实现,可合并行和列)
using System; using System.IO; using System.Data; using System.Reflection; using System.Diagnostics; ...
- Fluent NHibernate other example
测试用的当前最新版本: sql: --- CREATE TABLE Users ( UserID INT IDENTITY(1,1) PRIMARY KEY, [Name] VARCHAR(50) N ...
- js 自带的 reduce() 方法
1.方法说明 , Array的reduce()把一个函数作用在这个Array的[x1, x2, x3...]上,这个函数必须接收两个参数,reduce()把结果继续和序列的下一个元素做累积计算,其效果 ...
- double 类型转化为Integer类型 ---DecimalFormat
假设x是你要转换的double类型变量: 不进行四舍五入操作: (int)x 进行四舍五入操作: Integer.parseInt(new java.text.DecimalFormat(" ...
- 设置让ASP.NET管道接收所有类型的请求
在web.config文件添加如下一段配置: <configuration> <system.webServer> <modules runAllManagedModul ...
- 如何rename sqlserver database
Problem Sometimes there is a need to change the name of your database whether this is because the or ...
- 关于ArcGIS10.0中的栅格计算中的函数
版本升级确实很重要,在ArcGIS10.1中计算成功的,在10.0中出了问题. 问题 在进行栅格计算时,计算公式很简单,包括两个Ln函数: "-22.73 + 11.1 * Ln(5) + ...
- JavaScript中的ParseInt("08")和“09”返回0的原因分析及解决办法
今天在程序中出现一个bugger ,调试了好久,最后才发现,原来是这个问题. 做了一个实验: alert(parseInt("01")),当这个里面的值为01====>07时 ...