这个题是一个很简单的等比数列。

  题目大意是:初始第一步 $ n_1 = 2 $,之后的每一步都比前一步减少 98%,即满足等比数列 $ 2 + 2 \times 0.98 + 2 \times 0.98^2 + \cdots \leq K $ ,K 为某个上限值。

  利用 $ K = S_n = \frac{2 (1 - 0.98)^n}{1 - 0.98} \Rightarrow n = log_{0.98} (1 - \frac{K}{100}) $

  貌似 math.h/cmath 中的log没有能指定任意底数的,但注意到 $ log_a b = \frac{log_c b}{log_c a} $,所以也能计算。

  代码:

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define min(a, b) ((a) < (b) ? (a) : (b))
int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);}
const int N = 1500000;
int main()
{
double dis; int n;
scanf("%lf", &dis);
n = (int)ceil(log(1 - dis/100.)/log(0.98));
return printf("%d\n", n), 0;
}

  

P1432的更多相关文章

  1. 洛谷P1432 倒水问题(CODEVS.1226)

    To 洛谷.1432 倒水问题 题目背景 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were co ...

  2. 洛谷P1432 倒水问题

    题目背景 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with th ...

  3. 洛谷 P1432 倒水问题

    目录 题目 思路 \(Code\) 题目 戳 思路 \(bfs\) 第一遍提交\(50\),第二遍就\(100\)了,qwq \(Code\) #include<iostream> #in ...

  4. entity framework core 支持批量插入,值得期待

    entity framework6.x之前搞了这么多版本,构架这么牛B,居然没有批量插入更新的功能,但有很多替换的解决方案,例如Entity Framework Extended Library(ht ...

随机推荐

  1. amazon 1

    # 跨境电商 Amazon 丰富强大的海外站 开店流程 https://www.cifnews.com/article/48921 注册事项以及二审怎么过 https://www.cifnews.co ...

  2. 三、ZigBee无线网络工具

    CC2530概述 CC2530是德州仪器Ti公司用于2.4-GHz IEEE 802.15.4.ZigBee 和 RF4CE 应用的一个真正的片上系统(SoC)解决方案,是作为ZigBee无线传 感网 ...

  3. Linux - Deepin Linux,intel无线网卡下载慢、不能跑满宽带的解决方案

    解决方案 将 /etc/modprobe.d/iwlwifi.conf中的11n_disable=1删掉,重启. 参考 https://bbs.deepin.org/forum.php?mod=vie ...

  4. 关于jquery改变onclick方法,最保险的做法

    function a(){ alert("a"); } function b(){ alert("b"); } <input type="but ...

  5. AcWing 8.二维费用的背包问题

    #include<iostream> #include<algorithm> #include<cstring> using namespace std ; ; i ...

  6. 创建集群corosync

    #环境准备 #设置主机名解析yum -y install pcs pacemaker corosync fence-agents-allsystemctl start pcsd.servicesyst ...

  7. C语言编译和链接详解(通俗易懂,深入本质)

    我们平时所说的程序,是指双击后就可以直接运行的程序,这样的程序被称为可执行程序(Executable Program).在 Windows 下,可执行程序的后缀有.exe和.com(其中.exe比较常 ...

  8. 做新时代的奋斗者!(好吧,我还没弄出python的编译环境)

    Pictures: 今日分来的补记来嘞: Game 1:Guess the number. Python包含许多内建的函数,有些函数存在于称为模块的单独的程序中,可以使用import语句把它们的模块导 ...

  9. ThinkPhp5 中Volist标签的用法

    Volist标签一般是和内置方法assign()搭配使用,将值从后台传到前台,是当下比较流行的一种传值方法 本文实例讲述了ThinkPHP模板循环输出Volist标签用法.分享给大家供大家参考,具体如 ...

  10. AcWing 854. Floyd求最短路 多源 邻接矩阵

    //不存在负权回路 //边权可能为负数 #include <cstring> #include <iostream> #include <algorithm> us ...