Burning Midnight Oil CodeForces - 165B

晶晨64位S905S912烧写工具USB_BurningTool_v2.0.5.15-build9 amlogic晶晨固件烧写工具USB_BurningTool_v2.0.5.15-build9,适用于S905、S912系列64位arm CPU。 立即下载

Burning Midnight Oil

CodeForces - 165B

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup of tea, then he writes lines and so on: , , , ...

The expression is regarded as the integral part from dividing number a by number b.

The moment the current value equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.

Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.

Input

The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.

Output

Print the only integer — the minimum value of v that lets Vasya write the program in one night.

Example
Input
7 2
Output
4
Input
59 9
Output
54
Note

In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.

In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.

这个题用二分,只要是遇到可以从头到尾遍历暴力检查的题目,那就可以用二分。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int n,k;
int q_pow(int a,int b){//快速幂,这道题用不用都一样
    int ans = 1;
    while(b){
        if(b&1){
            ans *= a;
        }
        b >>= 1;
        a *= a;
    }
    return ans;
}
int check(int v){//检查是否符合题意
    int i = 0;
    int sum = 0;
    while(v/q_pow(k,i)){
        sum += (v/q_pow(k,i));
        i++;
        if(sum >= n)return 1;
    }
    return 0;
}
int main(){
    scanf("%d%d",&n,&k);
    int l = 1,r = n;
    while(l <= r){//二分查找
        int mid = (l+r)/2;
        if(check(mid)){
            r = mid-1;
        }
        else{
            l = mid+1;
        }
    }
    printf("%d\n",l);
    return 0;
}


晶晨S912-S905 -S805刷机工具Burning-Tool-v2.0.5.15-build9 晶晨S912-S905 -S805刷机工具Burning_Tool_v2.0.5.15-build9 立即下载

相关推荐

天猫魔盒M13刷机工具USB_BurningTool_v2.0.5.13支持64位cpu

天猫魔盒M13刷机工具USB_BurningTool_v2.0.5.13支持64位cpu 适用于S905、S912系列64位arm CPU

CodeForces - 165B Burning Midnight Oil ——二分

B. Burning Midnight Oil time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day a highly important task was

Lngxling的博客 314

对西安交大轴承数据集XJTU-SY_Bearing_Datasets进行读取和处理:

故障诊断,对西安交大轴承数据集XJTU-SY_Bearing_Datasets进行读取和处理

qq_44757503的博客 6079

B. Burning Midnight Oil

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day a highly important task was commissioned to Vasya — writ

无知的我 1672

模板匹配加速之金字塔分层搜索

图像金字塔是一种多分辨率图像表示方法,它通过一系列逐渐缩小或放大的图像来表示原始图像的不同尺度。高斯金字塔(Gaussian Pyramid):通过不断下采样(降采样)生成更小的图像。拉普拉斯金字塔(Laplacian Pyramid):通过高斯金字塔和差分操作生成一组残差图像。在模板匹配中,我们主要使用高斯金字塔来实现多尺度匹配。金字塔灰度模板匹配通过多尺度搜索策略,在保持较高准确率的同时显著提升匹配速度,尤其适用于:高分辨率图像处理实时检测系统移动端设备等资源受限场景。

weixin_44969144的博客 1742

自动驾驶仿真(五)—— 基于Carsim、Prescan、Simulink的联合仿真

自动驾驶仿真五——基于Carsim、Prescan、Simulink的联合仿真1. 联合仿真流程2. CarSim联合仿真配置要点3. Prescan联合仿真配置要点4. Carsim、Prescan、Simulink联合仿真结果5. 参考学习的书目教材 博主前面的博文已经介绍了Carsim和Prescan各自与Matlab/Simulink的相关联合仿真应用实例,并且论述过几款软件各自的优势及用法,CarSim适合动力学模型的建立,PreScan适合行车场景的搭建,Simulink适合控制算法的设计及信号

zhudj08的博客 1万+

Codeforces 165B Burning Midnight Oil 【二分】

题目链接:Codeforces 165B Burning Midnight OilB. Burning Midnight Oil time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output One day a highly importan

世界很大 989

python知网爬虫论文pdf下载+立即可用(动态爬虫)

python实现动态爬虫知网论文,搜索+自动翻页+下载 收集数据利器

Braylon的博客 5385

CodeForces - 165B Burning Midnight Oil

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes

qqchanmingdexiaji的博客 314

Homebrew高效升级与国内镜像源配置全攻略

本文详细介绍了如何通过配置国内镜像源(如清华、中科大、阿里云)来高效升级Homebrew,解决国内开发者访问GitHub仓库速度慢的问题。文章提供了从基础配置到永久生效的完整教程,包括常见问题解决和进阶技巧,帮助开发者大幅提升软件包管理效率。

weixin_28835551的博客 424

华为昇腾云平台适配Baichuan2大模型记录

文件发现报错:ValueError: The pipeline stage 2 in auto_parallel_context is not equal to the pipeline_stage 1 in the config.run_baichuan2_7b.yaml`,发现默认设备数是16卡,对应的pipeline_stage为2,但实际是8卡,那就改成下面的试试看。,将Baichuan2_7B_Chat.ckpt文件复制进去,将。点击镜像管理,突然发现有个2_2_0,赶紧新建了一个,成功。

羊城迷鹿的博客 2397

CodeForces - 165B Burning Midnight Oil (二分)

题目链接:http://codeforces.com/problemset/problem/165/B点击打开链接 B. Burning Midnight Oil time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu

xuejye的博客 339

FPGA实现串口升级及MultiBoot(十)串口升级SPI FLASH实现

采用软核进行串口升级的原因主要有以下几点:1、官方推荐:官方以前也推出了针对逻辑进行升级的程序《XAPP1081_QuickBoot》,但是从今年起(2024年)官方就停止更新相关例程了(详见下面截图),所以采用官方推荐的软核更新;2、简单并具有通用性:针对SPI或者BPI官方都有相关的IP,可应对市场上80%以上的FLASH,并且官方IP通用性极强,只需要修改几个参数就可以对不同厂家的芯片进行升级操作;

OpenFPGA的博客 2006

CodeForces 165B - Burning Midnight Oil(二分)

B. Burning Midnight Oil time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day a highly important task was

coco430的专栏 1076

Taro React组件使用(5) —— RuiPasswordInput 密码输入框显示隐藏和清空

初始化时,需要将传入的 value 赋值给当前组件的 value, 不能直接修改 props 的 value;在组件内输出组件内的变量时,最好先判断输出函数是否定义,再输出,否则很容易引起报错。

止于至善 895

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

B - Burning Midnight Oil CodeForces - 165B  (二分)

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes

wjmwsgj的博客 652

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

[补]CodeForces 165B Burning Midnight Oil

B. Burning Midnight Oiltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day a highly important task was commissioned to Vasya — writing a progr...

ZXM_ZhanX的博客 401

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

CodeForces 165B Burning Midnight Oil

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v 

CS33sun的博客 405

codeforces 165B Burning Midnight Oil

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34301132的博客 116

B - Burning Midnight Oil CodeForces - 165B

B - Burning Midnight Oil One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works li

benniaoyizhi的博客 555

CodeForces 165B Burning Midnight Oil(二分)

题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=114355#problem/B 代码: #include #include using namespace std; __int64 n,k; int judge(__int64 x) { __int64 ans=1; __int64 kk=k; _

Pig_Me的博客 487

codeForces 165B.Burning Midnight Oil(二分)

题意:给你两个数字N,K。N表示有个人要写N行东西,K是跟他的写东西效率有关的额一个系数。这个人写东西写一会就累了就必须喝杯茶再写,他的效率会越来越低,V表示他第一天能写V行,然后依次能写等等,当这个值为零时他就睡着了。问你V最小为多少时,他才能写完这N行东西? 思路:二分V,

张松超的博客 515
上一篇: 第39级台阶
下一篇: Another Problem on Strings CodeForces - 165C
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值