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小的那一个数 短板效应嘛 ...
随机推荐
- 551. Student Attendance Record I 从字符串判断学生考勤
[抄题]: You are given a string representing an attendance record for a student. The record only contai ...
- 内存cache使用的场景
Q.业务场景内为什么要使用内存cache? A.为了利用内存cache的优点, 解决业务场景内的缺陷 Q.内存cache的优点和缺点 A.优点: 内存读写速度比磁盘块 缺点: 内存空间有限, 内存单价 ...
- linux c 获取系统时间
#include <time.h> main() { time_t timep; time (&timep); printf(“%s”,asctime(gmtime(&ti ...
- ubuntu 设置虚拟机和主机在同一网段
一.在VMware中将网络连接方式设置为桥接 1.打开VM菜单栏->Settings 2.在弹出的Virtual Machine Setting对话框中点击Network Adapter,在右边 ...
- c语言实践 用1角 2角 5角 凑成10元钱的方法
/* 用1角,2角,5角凑出10元钱,有几种办法. 也就是0.1a+0.2b+0.3c=10,化简一下就是 a=100-2b-3c 因为a的范围是0到100,所以弄一个循环 把a的值从0尝试到100, ...
- 安装sql server 2008重启失败
sql server2008安装时提示重启计算机失败怎么办 安装SQL Server 2008时,经常会遇到这样一个问题,软件提示“重启计算机失败”,如果忽略的话,会给后面的安装带来很大的麻烦,这 ...
- IIS关闭Trace、OPTIONS方法
方法(1):web.config 在<configuration>节点下添加如下代码: <system.webServer> <security> <requ ...
- Date3.19
1.正则表达式的定义及使用2.Date类的用法3.Calendar类的用法========================================================1正则表达式的 ...
- HYSBZ 1036 树的统计Count (水题树链剖分)
题意:中文题. 析:就是直接维护一个最大值和一个和,用线段树维护即可,这个题很简单,但是我卡了一晚上,就是在定位的时候,位置直接反过来了,但是样例全过了...真是... 代码如下: #pragma c ...
- C# JSON使用的常用技巧(二)
JSON在php里一句json_encode就可以得到 在C#里我们同样也很容易的可以得到 用到的类库:Newtonsoft.Json.dll 实体类: class Cat { public stri ...