CodeForces - 165B Burning Midnight Oil (二分)

grafana使用方法 1、点击仪表盘2、新建仪表盘3、选择数据源4、选择查询的条件5、美化。 阅读详情

题目链接: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 input
output
standard output

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.

Examples
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.



因为没算一个数是否达到的复杂度是log级别的

因此可以用二分再降一个log

#include <bits/stdc++.h>
using namespace std;
int cal(int v,int k)
{
	int sum=0;
	while(v)
	{
		sum+=v;
		v=v/k;
	}
	return sum;
}
int main()
{
	int n,k;
	cin >>n >>k;
	int mid=n;
	int ans=0;
	int l=0;
	int r=1e9;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(cal(mid,k)>=n)
		{
			ans=mid;
			r=mid-1;
		}
		else
			l=mid+1;
	}
	cout <<ans <<endl;
}





【Bug已解决】Context window exceeded / Token limit reached — Claude Code 上下文窗口超限解决方案 Claude Code 长会话中报上下文窗口/Token 超限,本质是对话历史、文件内容、工具结果累积超过 200K 上限。文中给出 /clear、/compact、分批读大文件、限制工具输出、配置 autoCompact 等完整方案。 阅读详情

相关推荐

银河麒麟V10 SP1忘记密码?3分钟搞定单用户模式密码重置(附详细截图)

本文详细介绍了银河麒麟V10 SP1操作系统忘记登录密码后的应急恢复方法。核心是通过GRUB引导菜单进入单用户模式,无需密码即可获得root权限,从而快速重置用户密码。文章提供了从捕捉GRUB界面、编辑启动参数到执行密码修改命令的完整步骤图解与常见问题解决方案,帮助用户在几分钟内恢复系统访问。

w3x4y的博客 947

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

b站up“麦辣翅翅”《YOLOv8修改损失函数》问题解决RuntimeError: The size of tensor a (4) must match the size of tensor

b站up“麦辣翅翅”《YOLOv8修改损失函数》问题解决RuntimeError: The size of tensor a (4) must match the size of tensor ;TypeError: bbox_iou() got an unexpected keyword argument 'xywh‘

weixin_68331871的博客 3029

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

别再乱点U盘里的.exe了!手把手教你彻底清除那个伪装成Usb Disk的蠕虫病毒

本文详细介绍了如何识别、清除和预防伪装成Usb Disk的蠕虫病毒。从识别感染迹象到安全备份文件,再到深度清理病毒残留和构建防护策略,提供了一套完整的U盘病毒解决方案。特别提醒用户注意U盘病毒的风险,并养成良好的使用习惯。

weixin_30496999的博客 730

为什么BGA焊点总在四个角先坏?一次热-振耦合仿真给你讲明白

本文通过Ansys Workbench进行热-振耦合仿真,深入分析了BGA焊点在四个角点先失效的机理。研究发现,角点焊点由于CTE失配、振动载荷放大及几何应力集中等因素,承受的等效塑性应变和动态应力显著高于中心区域,导致其疲劳寿命大幅降低。仿真数据揭示了角点焊点的应力分布和蠕变特性,为电子封装可靠性设计提供了重要依据。

weixin_42535461的博客 441

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

华为OD机考双机位C卷 - AI处理器组合 (Java & Python & JS & GO & C++ & C)

> 2026华为OD机试双机位C卷 - 华为OD上机考试双机位C卷 华为OD机试双机位C卷真题目录点击查看: [【全网首发】2026华为OD机位C卷 机考真题题库含考点说明以及在线OJ(OD上机考试双机位C卷)](https://blog.csdn.net/banxia_frontend/article/details/155503868)

算法大师! 237

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

Ubuntu零基础入门到精通【4.4讲】:网络、蓝牙、显示器、声音与输入法设置!

🏆 本文收录于 《滚雪球学 Ubuntu》 专栏。 本专栏面向有一定计算机基础,但尚未系统学习 Linux / Ubuntu 的读者,采用“滚雪球式学习法”:先装好、再会用、再理解、再优化、再实战,带你从第一次进入 Ubuntu 桌面 / 终端开始,逐步掌握 Ubuntu 的日常使用、命令操作、软件安装、系统配置、开发环境搭建与服务器部署能力。

**My Coding Family** 1492

构建一个基于Simulink的LC滤波器仿真模型

需求分析LC滤波器(Inductor-Capacitor Filter)是一种常见的无源滤波器,广泛应用于电力电子、通信、音频处理等领域。其主要作用是平滑输入信号中的高频谐波成分,保留低频或直流成分,从而提高输出信号的质量。在电力电子系统中,LC滤波器常用于逆变器、整流器等设备的输出端,以减少开关噪声和电磁干扰(EMI),确保输出电压和电流的稳定性。本项目将基于Simulink平台,开发一个完整的LC滤波器仿真模型,涵盖从电源输入到滤波输出的整个过程,并通过PI控制器实现对滤波效果的闭环控制。

MHD0815的博客 749

cf 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

Clearlemon 898

AI Agent的知识蒸馏链:多阶段LLM模型优化

随着大语言模型(LLM)规模的不断扩大,如何在保持模型性能的同时提高其部署效率成为关键挑战。本文旨在探讨通过知识蒸馏技术构建多阶段优化链,实现LLM模型的高效压缩和性能优化。研究范围涵盖从基础理论到实际应用的完整知识蒸馏流程,特别关注AI Agent场景下的特殊需求和解决方案。本文首先介绍知识蒸馏的基本概念和背景,然后详细阐述多阶段蒸馏链的核心原理。接着,我们将深入探讨算法实现细节和数学模型,提供完整的代码示例。最后讨论实际应用、工具资源和未来发展方向。

AI大模型应用之禅 358

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

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

NTscan扫描工具

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

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

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,

张松超的博客 516

codeforces 165B - Burning Midnight Oil codeforces 【二分+快速幂】

#include<bits/stdc++.h> #define ll long long using namespace std; ll powp(int k, int l){//快速幂 ll i, j, sum = 1; for(i = 1; i <= l; i++) { sum*=k; } return sum; } int cheak(int m, int k...

OOOak 194

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

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

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

codeforces 165B Burning Midnight Oil

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

weixin_34301132的博客 116

B. Burning Midnight Oil Codeforces Round 112 (Div. 2)

题目大意:最后写了至少n个,每次衰减k倍(/k),问最初的v最小为多少。 思路&方法:二分答案。

halation_Z的博客 337

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
上一篇: HDU - 1058 Humble Numbers (2 3 5 7丑数)
下一篇: CodeForces - 915B Browser (模拟)
xuejye
博客等级 码龄9年 35粉丝 297原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值