CodeForces 165B Burning Midnight Oil

SAP成本控制范围配置全流程:从货币参数到标准层次(附2024最新SPRO路径) 本文详细拆解了SAP成本控制范围(Controlling Area)的完整配置流程,涵盖从货币与估价参数文件定义、参数文件分配到控制范围,再到成本中心标准层次创建等核心步骤。文章提供了2024年最新的SPRO导航路径和实战配置要点,帮助顾问构建稳健、可扩展的管理会计基础架构,并附有常见问题排查指南。 阅读详情

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 <stdio.h>
#include <string.h>
int n, k;
int judge(int m) {
	int sum = m;
	while(m) {
		sum += m/k;
		m /= k;
	}
	if(sum >= n) return 1;
	else return 0;
}
int main() {
	while(~scanf("%d%d",&n,&k)) {
		int ans;
		int l = 1;
		int r = n;
		while(l <= r) {
			int m = l+(r-l)/2;
			if(judge(m)) {
				ans = m;
				r = m-1;
			}
			else l = m+1;
		}
		printf("%d\n",ans);
	}
	return 0;
}


INCA ProF文件解析 本博文从实际应用出发,介绍INCA prof文件的关键信息,通过实例,描述当得到一个刷写需求后,如何在不改变用户之前的使用习惯的前提下,满足原有的INCA刷写应用数据和标定程序的需求。 声明:本文不涉及项目名称,没有商业目的,纯属分享技术,乐享知识。 阅读详情

相关推荐

ROS专栏—基于STM32F103的INA219电源数据采集

文章主要记录了stm32f103对ina219的数据采集

热爱生活、奋斗前行 2354

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

无知的我 1670

【Python脚本】Python自动大麦网抢票,准点原价秒杀演唱会门票,拒绝黄牛交易!从我做起!!!1

你是否错过了周杰伦的票,最近又没抢到五月天的票,不要太难过,今晚有张学友的票,后天还有张杰的票,加油哦!

weixin_45841831的博客 6万+

[补]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

【AUTOSAR-DCM】-3.1-将CDD导入CFG并查看$22服务配置变化(UDS诊断DID带一个Data)

案例背景:(共8页精讲) 在《【UDS诊断描述文件CDD】-3.2-编辑CDD给$22服务创建一个带一个Data的DID(dataIdentifier)数据标识符》中,适应使用CANdela Studio在CDD中创建一个带一个Data的DID(dataIdentifier)数据标识符,见图0-1。现在我们将该CDD文件导入到CFG(DaVinci Configurator),看看配置会发生哪些变化。 图0-1 目录 1 将诊断描述文件CDD导入CFG(DaVinci Configurator.

「汽车电子助手」的博客 1633

【PowerBI专栏】PowerBI导入MYSQL数据库

本文介绍了在PowerBI中连接MySQL数据库的方法。首先需要下载并安装MySQL官方.NET连接驱动(推荐8.4.0版本),安装完成后重启PowerBI。连接时需填写服务器IP和数据库名称等必填参数。文章详细说明了连接配置步骤,包括账户设置、数据表选择以及可能遇到的数据格式转换问题处理。最后指导用户完成数据清洗后进入PowerPivot进行后续计算。特别提醒最新9.4版本可能存在兼容性问题,建议使用稳定的8.4版本连接器。

技术与管理的平衡木- 691

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

openclaw通俗入门系列6——记忆系统

记忆 = 智能体的笔记本,分长期(MEMORY.md)和每日(memory/日期.md)。只有写到文件里的才能记住!支持语义搜索(理解意思)+ 关键词搜索,还能自动在压缩前保存重要内容。

m0_60605453的博客 403

Burning Midnight Oil

DescriptionOne 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 h

Jane的私房菜 940

视源CVTE嵌入式面试题及参考答案(200+面试题,17万字)

内核模块如何设置? 内核模块是可在运行时动态加载到内核或从内核卸载的代码块。以下是设置内核模块的步骤: 首先,编写内核模块代码。通常使用 C 语言编写,包含必要的头文件,如<linux/init.h>、<linux/module.h>等。在代码中,需要定义模块的初始化函数和清理函数。初始化函数在模块加载时被调用,用于进行模块的初始化工作,如注册设备、分配资源等。清理函数在模块卸载时被调用,用于释放资源、注销设备等。 例如: #include <li

大模型大数据攻城狮的专栏 2204

大疆 2021 嵌入式笔试题

在深圳做嵌入式,大疆公司绝对是 Top 级别的,大疆的技术栈也很深。

qq_38769551的博客 2496

CodeForces 165B Burning Midnight Oil(二分水题)

#include #include #include #include #include #include #include #include using namespace std; const int maxn = 22222; const int maxt = 100200; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; co

fly_tzf的博客 474

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

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的博客 313

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

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的专栏 1074

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的博客 651

codeforces 165B Burning Midnight Oil

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

weixin_34301132的博客 116

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的博客 313

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

Burning Midnight Oil CodeForces - 165B

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 ex

codeswarrior的博客 778

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,

张松超的博客 514

codeforces 165B(Burning Midnight Oil)

【题意描述】 本题就是给定代码任务为n行,起始代码书写能力为v行,然后每经过一次除以k,当v变为0时看是否完成代码任务n?并求出最小的v。 【解题思路】 我们可以对v值进行二分,然后确定最后的v值。 【AC代码】 1 #include<iostream> 2 using namespace std; 3 int ok(int v,int k) 4 { 5...

weixin_30652897的博客 144
上一篇: CodeForces 208B Solitaire
下一篇: POJ 1611 The Suspects
追逐星辰的光
博客等级 码龄10年 12粉丝 221原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值