求∑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 分块预处理的更多相关文章

  1. LightOJ 1234 Harmonic Number

    D - Harmonic Number Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu S ...

  2. LightOJ 1234 Harmonic Number (打表)

    Harmonic Number Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submi ...

  3. LightOJ 1234 Harmonic Number(打表 + 技巧)

    http://lightoj.com/volume_showproblem.php?problem=1234 Harmonic Number Time Limit:3000MS     Memory ...

  4. LightOJ - 1234 LightOJ - 1245 Harmonic Number(欧拉系数+调和级数)

    Harmonic Number In mathematics, the nth harmonic number is the sum of the reciprocals of the first n ...

  5. 1 。 LightOJ 1234 打表法(数据太大,把数据缩小100倍)

    原题链接http://acm.hust.edu.cn/vjudge/contest/121397#problem/A Description In mathematics, the nth harmo ...

  6. LightOJ 1234 Harmonic Number 调和级数部分和

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1234 Sample Input Sample Output Case : Case : ...

  7. wannafly 练习赛10 f 序列查询(莫队,分块预处理,链表存已有次数)

    链接:https://www.nowcoder.net/acm/contest/58/F 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524288K 64 ...

  8. bzoj 3576[Hnoi2014]江南乐 sg函数+分块预处理

    3576: [Hnoi2014]江南乐 Time Limit: 30 Sec  Memory Limit: 512 MBSubmit: 1929  Solved: 686[Submit][Status ...

  9. Trailing Zeroes (II) LightOJ - 1090(预处理+前缀和)

    求C(n,r)*p^q的后缀零 考虑一下 是不是就是求 10^k*m  的k的最大值 而10又是由2 和 5 组成  所以即是求 2^k1 * 5^k2 * m1 中k1和k2小的那一个数 短板效应嘛 ...

随机推荐

  1. SQL 数据库 学习 002 如何启动 SQL Server 软件

    如何启动 SQL Server 软件 我的电脑系统: Windows 10 64位 使用的SQL Server软件: SQL Server 2014 Express 如果你还没有下载 SQL Serv ...

  2. 25.AVG 函数

    定义和用法 AVG 函数返回数值列的平均值.NULL 值不包括在计算中. SQL AVG() 语法 SELECT AVG(column_name) FROM table_name SQL AVG() ...

  3. 用conda创建一个tensorflow 虚拟环境

    创建your——user——name = tensorflow 的虚拟环境 xinpingdeMacBook-Pro:~ xinpingbao$ conda create -n tensorflow ...

  4. laravel中的attach and detach toggle method

    创建模型 post  and  user 以及 users , posts ,user_post(favorities)测试数据 在此可以看上一篇中的数据,本次测试数据利用的上一篇的数据.detach ...

  5. oracle plsql参数

    declare inst_name varchar2(100); cursor mycur is select * from tran_forward t where t.instrument_typ ...

  6. Part10-C语言环境初始化-一跃进入C大门lesson3

    1.跳转到c代码 因为内存中的代码来自于垫脚石SRAM,他们是相同的. 采用绝对跳转方式来完成. 因为我们是从汇编代码跳转到c语言的程序,所以我们要提前准备一个main.c文件. 修改makefile ...

  7. 网页中的foot底部定位问题

    有时候,我们会碰到这样一个问题. 网页底部一般有个foot对吧,放置一些友情链接版权声明什么的,这个模块是如何定位的? 要是直接放内容区域的下面的话,假如是内容区域的高度不够的话,那么foot下面是会 ...

  8. JavaScript 的 export default 命令

    export default 指定模块的默认输出,一个模块只能有一个默认输出. 举个例子. export-default.js export default { name: 'hello', data ...

  9. jsp-MySQL连接池

    1.将数据库驱动程序的JAR文件放在Tomcat的 common/lib 中: mysql-connector-java-5.1.18-bin.jar 下载地址:https://yunpan.cn/c ...

  10. 一张图看懂ASP.NET MVC5认证和授权过滤器的执行顺序

    IAuthenticationFilter是MVC5中的新特性,它有2个关键方法: OnAuthentication OnAuthenticationChallenge 当IAuthenticatio ...