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 ...
随机推荐
- luogu1896 [SCOI2005]互不侵犯 状压DP
题目大意 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子.( 1 <=N <=9, 0 ...
- poj--1274--The Perfect Stall(最大匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21665 Accepted: 973 ...
- Find a way--hdoj
Find a way Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 在linux上加速git clone
在linux上加速git clone 进入终端命令行模式,sudo vim /etc/hosts 编辑hosts文件,添加以下ip-域名,保存退出 151.101.44.249 github.glob ...
- website robots.txt 防爬虫 措施
robots.txt文件用法举例: 1. 允许所有的robot访问 User-agent: * Allow: / 或者 User-agent: * Disallow: 2. 禁止所有搜索引擎访问网站的 ...
- lua math.random()
math.random([n [,m]]) 用法:1.无参调用,产生[0, 1)之间的浮点随机数. 2.一个参数n,产生[1, n]之间的整数. 3.两个参数,产生[n, m]之间的整数. math. ...
- win 7环境下java环境变量的配置
http://www.cnblogs.com/zhj5chengfeng/archive/2013/01/01/2841253.html %Java_Home%\bin;%Java_Home%\jre ...
- css table布局
表格布局有两种方式: 1.HTML Table(<table>标签)和 2. CSS Table(display:table 等相关属性). HTML Table是指使用原生的<ta ...
- Pycharm 设置
1:显示行号 打上对勾OK 2:设置作者 & 文件编码 3:选择切换Python的版本
- 如何 打包整合linux系统文件夹 用于刷机包等等, 其中包括打包 句号开头 . 开头的文件, 排除系统文件 等
tar --exclude=proc/* --exclude=sys/* -cvjf rootfs.tar.bz2 * .[!.]* -R