璟雯院

珺璟如晔,雯华若锦

用户工具

站点工具


icpc:problems:luogup1150
problems
名称Peter 的烟
题目编号P1150
题目链接luogu.com.cn/…
来源Luogu
算法分类数学
难易程度容易

Peter 的烟

想法

设总共抽完$x$根烟,可换的烟头为$x-1$个,换出来的烟共有$x-n$只,则建立方程:

$$x - n = \frac{x - 1}{k}$$

代码实现

#include <cstdio>
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    printf("%d", n + (n - 1) / (k - 1));
    return 0;
}
/app/www/public/data/pages/icpc/problems/luogup1150.txt · 最后更改: 2024/04/20 14:45 由 温婕莺