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 ...
随机推荐
- 【视频】零基础学Android开发:蓝牙聊天室APP(一)
零基础学Android开发:蓝牙聊天室APP第一讲 1. Android介绍与环境搭建:史上最高效Android入门学习 1.1 Google的大小战略 1.2 物联网与云计算 1.3 智能XX设备 ...
- 【转】window 安装redis服务、卸载redis服务和启动redis服务
1.安装redis服务 redis-install.bat 1 echo install redis-server23 D:\redis\redis-server.exe --service-inst ...
- 创建我们第一个Monad
上一篇中介绍了如何使用amplified type, 如IEnumerable<T>,如果我们能找到组合amplified type函数的方法,就会更容易写出强大的程序. 我们已经说了很多 ...
- Py基础+中级
原文 Py学习博客 1:https://www.cnblogs.com/fu-yong/p/8060198.html2:while True:just do it 三.Python的默认编码 ▷pyt ...
- echarts 圆形图、柱状图
首先引入echarts的js包 <script type="text/javascript" src="js/esl.js"></script ...
- SQL数据库链接代码的解释
SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=(local);Initial ...
- Absolute Horizontal And Vertical Centering In CSS
Quick CSS Trick: How To Center an Object Exactly In The Center Centering in CSS: A Complete Guide Ab ...
- Docker的特性解析
Docker简介与入门:http://segmentfault.com/blog/p_chou/1190000000448808 Docker是个新生的事物,概念类似虚拟化.网上关于Docker入门的 ...
- 杭电2061WA
#include<stdio.h> struct mem { char s[50]; int c; int f; }; int main() { struct mem x[60]; int ...
- 项目随笔@Service("testService")-------第二篇
在springmvc中使用注解已经司空见惯了,今天见到了@Service("xxx")这种形式,让我大吃一惊.原来在service后面可以加参数,作为该service的名字,在sp ...