1008: 级数求和

题目描述

已知:Sn= 1+1/2+1/3+…+1/n。显然对于任意一个整数K,当n足够大的时候,Sn大于K。现给出一个整数K(1<=k<=15),要求计算出一个最小的n;使得Sn>K。

输入

输入 k

输出

输出 n

样例输入

3

样例输出

11
 
简单水题
不多说 附上代码:
#include <iostream>
#include<math.h>
#include <iomanip>
#include<cstdio>
#include<string>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<stdlib.h>
#include<iterator>
#include<sstream>
#include<string.h>
#include<stdio.h>
using namespace std; int main()
{
double a;
int k;
while(cin>>k)
{
double sum=;
a=; while(sum<=k)
{
sum=sum+1.0/(a+);
a++;
}
cout<<a<<endl;
} return ;
}
 
 

XCOJ 1008: 级数求和的更多相关文章

  1. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  2. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  3. POJ 1008 Maya Calendar

    链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  4. BZOJ 1008 题解

    1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7845  Solved: 3359[Submit][Status] ...

  5. HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)

    Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. 【BZOJ】1008: [HNOI2008]越狱(快速幂)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1008 刚开始看不会做啊,以为是dp,但是数据太大!!!所以一定有log的算法或者O1的算法,,,,还 ...

  7. PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)

    1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...

  8. PAT乙级 1008. 数组元素循环右移问题 (20)

    1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数,在不允 ...

  9. [ZOJ 1008]Gnome Tetravex (dfs搜索 + 小优化)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是 ...

随机推荐

  1. vue 无法热替换/热更新

    参考了小伙伴的解决办法: 1.https://blog.csdn.net/win7583362/article/details/65443291 虽然我并不是用对方的方法解决的. 依然还是建议大家打开 ...

  2. codeforces A. Zoning Restrictions Again

    A. Zoning Restrictions Again ou are planning to build housing on a street. There are n spots availab ...

  3. Codeforces Round #598 (Div. 3) C. Platforms Jumping

    There is a river of width nn. The left bank of the river is cell 00 and the right bank is cell n+1n+ ...

  4. ISE-Backup Data Type

    Cisco ISE allows you to back up data from the Primary PAN and from the Monitoring node. Back up can ...

  5. Spring 属性依赖注入

    1.1    属性依赖注入 依赖注入方式:手动装配 和 自动装配 手动装配:一般进行配置信息都采用手动 基于xml装配:构造方法.setter方法 基于注解装配: 自动装配:struts和spring ...

  6. 读写json文件

    def read_json(path): """return dict""" with open(path,'r+')as f: retur ...

  7. pysftp-tools

    import pysftp import paramiko import os import unittest import json import warnings warnings.filterw ...

  8. django model 高级进阶

    十.model高级用法: 10.1 ORM映射: Object Relational Mapping: orm映射的任务: 将list ,object 的操作转化为sql语句,根据对象生成数据表,将查 ...

  9. 了解Maven的基本知识

    我的博客地址:https://www.cnblogs.com/themysteryofhackers/p/11934540.html 更新时间:2019-11-26 一.Maven的基本概念 Mave ...

  10. socket udp编程的一些积累的记录

    接了个小活,要求写udp的客户端,循环接收服务端的固定的指令并显示数据 我设计的逻辑是,用户在界面输入框输入服务器ip.端口,随后udp连接,开启线程循环接收,接收指令,解析成数据,存在结构体的lis ...