HDU 4342
先确定M的大致范围后即可求。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define LL __int64
#define N 60000 LL square[N];
LL spre[N]; void init(){
spre[0]=0; spre[0]=0;
for(LL i=1;i<N;i++){
square[i]=i*i;
spre[i]=spre[i-1]+i*(2*i+1);
}
} int main(){
init();
int T,n;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
LL p=(LL)sqrt(n*1.0);
if(square[p+1]-p-1<n)
p++;
LL g=n-(square[p]-p)+square[p];
LL su=spre[p-1]+p*(g-square[p]+1);
printf("%I64d %I64d\n",g,su);
}
}
HDU 4342的更多相关文章
- hdu 4342 History repeat itself(数学题)
题目链接:hdu 4342 History repeat itself 题意: 让你找第a个非完全平方数m,并且求前m个数的开方向下取整的和. 题解: 第一个问题: 假设第a个非平方数是X,X前面有n ...
- HDU 4342——History repeat itself——————【数学规律】
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...
- 【HDU - 4342】History repeat itself(数学)
BUPT2017 wintertraining(15) #8C 题意 求第n(n<2^32)个非完全平方数m,以及\(\sum_{i=1}^m{\lfloor\sqrt i\rfloor}\) ...
- 2012 #5 History repeat itself
History repeat itself Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- 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 ...
随机推荐
- VirtualBox 5.1.14 获取VirtualBox COM对象错误
Oracle VM VirtualBox 5.1.14 安装完成之后显示错误, Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but C ...
- BZOJ 1537 cdq分治
思路: 我只是想写一下cdq-- 二维偏序 一维排序 一维cdq分治 (我忘了归并排序怎么写了,,,) 写了个sort- 复杂度是O(nlog^2n) //By SiriusRen #include ...
- 利用@factory和@dataProvider实现参数化
利用构造函数将要用的的参数初始化,非常有利于简化脚本.它将外部的数据赋给本地的变量,可以使得初始化后的参数被其他方法使用.直接上代码: private String url; private S ...
- C#怎么清除字符串中HTML标签。。。
因为用到了一款编辑器的原因,使得数据库中保存的数据会夹杂着一些HTML标签,之后导出的数据中就会出现一些不同的HTML的标签.严重影响用户的视觉体验(主要自己都看不下去了)... 下面是我将DataT ...
- lua中.和:的区别
local myTable = {} function myTable:putMyname(val) print(val) print(self and self.name) end myTable. ...
- 5.Project常用操作介绍
Project常用操作介绍 1.项目浏览器 2.项目属性 Name:项目名称 Category:项目组织结构 Author:作者 Copyright:版权 Image:项目图标 Description ...
- 剖析Promise内部结构,一步一步实现一个完整的、能通过所有Test case的Promise类
本文写给有一定Promise使用经验的人,如果你还没有使用过Promise,这篇文章可能不适合你,建议先了解Promise的使用 Promise标准解读 1.只有一个then方法,没有catch,ra ...
- 在APP开发设计过程中:如何设计启动页面?
心理学上有一个“7秒理论”,说的是,一个人对另一个人的印象,在初次见面的七秒内就会形成,最近更有研究表明,这个时间可能更短——不到1秒.所以初次见面所展示的形象真的很重要.同理,用户在使用APP时,每 ...
- oracle 编译包的时候,一直提示正在编译
select b.sid,b.serial#,b.machine,b.terminal,b.program,b.process,b.status from v$lock a , v$session b ...
- (转)RabbitMQ学习之Headers交换类型(java)
http://blog.csdn.net/zhu_tianwei/article/details/40923131 Headers类型的exchange使用的比较少,它也是忽略routingKey的一 ...