LightOJ - 1234 分块预处理
求∑1/i,但是范围很大
和bitmap的想法一样,分个块,均摊复杂度就降下来了
//到底排行榜上的0ms是怎么做到的?
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+11;
const int N = 1e8;
double tmp[N/128+7];
int main(){
double t=0;
for(int i = 1; i <= N; i++){
t+=(double)1/i;
if(i%128==0) tmp[i/128]=t;
}
int T,kase=0; scanf("%d",&T);
while(T--){
int n; scanf("%d",&n);
int divi=n/128,remi=n%128;
double ans=tmp[divi];
for(int i = 1; i <= remi; i++){
ans+=(double)1/(divi*128+i);
}
printf("Case %d: %.10lf\n",++kase,ans);
}
return 0;
}
LightOJ - 1234 分块预处理的更多相关文章
- LightOJ 1234 Harmonic Number
D - Harmonic Number Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu S ...
- LightOJ 1234 Harmonic Number (打表)
Harmonic Number Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- LightOJ 1234 Harmonic Number(打表 + 技巧)
http://lightoj.com/volume_showproblem.php?problem=1234 Harmonic Number Time Limit:3000MS Memory ...
- LightOJ - 1234 LightOJ - 1245 Harmonic Number(欧拉系数+调和级数)
Harmonic Number In mathematics, the nth harmonic number is the sum of the reciprocals of the first n ...
- 1 。 LightOJ 1234 打表法(数据太大,把数据缩小100倍)
原题链接http://acm.hust.edu.cn/vjudge/contest/121397#problem/A Description In mathematics, the nth harmo ...
- LightOJ 1234 Harmonic Number 调和级数部分和
题目链接:http://lightoj.com/volume_showproblem.php?problem=1234 Sample Input Sample Output Case : Case : ...
- wannafly 练习赛10 f 序列查询(莫队,分块预处理,链表存已有次数)
链接:https://www.nowcoder.net/acm/contest/58/F 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524288K 64 ...
- bzoj 3576[Hnoi2014]江南乐 sg函数+分块预处理
3576: [Hnoi2014]江南乐 Time Limit: 30 Sec Memory Limit: 512 MBSubmit: 1929 Solved: 686[Submit][Status ...
- Trailing Zeroes (II) LightOJ - 1090(预处理+前缀和)
求C(n,r)*p^q的后缀零 考虑一下 是不是就是求 10^k*m 的k的最大值 而10又是由2 和 5 组成 所以即是求 2^k1 * 5^k2 * m1 中k1和k2小的那一个数 短板效应嘛 ...
随机推荐
- CF 961G Partitions
推不动式子 我们考虑每一个$w_i$对答案的贡献,因为题目中定义集合的价值为$W(S) = \left | S \right |\sum_{x \in S}w_x$,这个系数$\left | S \r ...
- pip指定安装包版本
pip是目前最好用的python包关系工具,没有之一. 1.版本范围符号:==.>=.<=.>.<. 2.单个安装示例: 1 2 3 pip install cchardet ...
- 数据库 MySQL 之 数据操作
数据库 MySQL 之 数据操作 一.MySQL数据类型介绍 MySQL支持多种类型,大致可以分为四类:数值.字符串类型.日期/时间和其他类型. ①二进制类型 bit[(M)] 二进制位(101001 ...
- jquery dropdownlist.js
$.fn.extend({ SetDict: function (option) { var txtControl = $(this); if (!txtControl.hasClass(" ...
- SQL语句性能分析常用命令
DBCC freeproccache DBCC dropcleanbuffers 1.set statistics IO {ON| OFF} /*Transact-SQL 语句生成的磁盘活动量的信息* ...
- The Three Models of ASP.NET MVC Apps
12 June 2012 by Dino Esposito by Dino Esposito We've inherited from the original MVC pattern a ra ...
- HDU 2829 Lawrence (斜率优化DP或四边形不等式优化DP)
题意:给定 n 个数,要你将其分成m + 1组,要求每组数必须是连续的而且要求得到的价值最小.一组数的价值定义为该组内任意两个数乘积之和,如果某组中仅有一个数,那么该组数的价值为0. 析:DP状态方程 ...
- HDU 3333 Turing Tree (主席树)
题意:给定上一个序列,然后有一些询问,求区间 l - r 中有多少个不同的数的和. 析:和求区间不同数的方法是一样,只要用主席树维护就好. 代码如下: #pragma comment(linker, ...
- 编写高质量代码改善C#程序的157个建议——建议7: 将0值作为枚举的默认值
建议7: 将0值作为枚举的默认值 允许使用的枚举类型有byte.sbyte.short.ushort.int.uint.long和ulong.应该始终将0值作为枚举类型的默认值.不过,这样做不是因为允 ...
- Jackson Streaming API to read and write JSON
Jackson supports read and write JSON via high-performance Jackson Streaming APIs, or incremental mod ...