/**
* projectName: luogu
* fileName: P1150.java
* packageName: com.gxuwz.yixin
* date: 2021年11月28日上午9:30:07
*/
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(); // 香烟的个数
int k = scanner.nextInt(); // 烟蒂的个数
int result = n; // 将香烟的个数赋给 result
int x = 1;
x = n/k;
int yu = n%k; // 求余数
while(x>0) { // 如果除数大于 0 证明可以换烟
result += x;
x += yu; // 每次做除法的时候,可能还会剩一些烟蒂,比如例子中, 4/3 , 商1余1,也就是只能换1根,还剩一根烟蒂,那么这一根烟蒂要放到下一次计算中
if(x>=k) { // 只有除数大于 烟蒂的个数时再算余数
yu = x%k;
}else {
yu = 0;
# **最后**
分享一些系统的面试题,大家可以拿去刷一刷,准备面试涨薪。
**这些面试题相对应的技术点:**
* JVM
* MySQL
* Mybatis
* MongoDB
* Redis
* Spring
* Spring boot
* Spring cloud
* Kafka
* RabbitMQ
* Nginx
* ......
**大类就是:**
* Java基础
* 数据结构与算法
* 并发编程
* 数据库
* 设计模式
* 微服务
* 消息中间件
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/c8a941dcfea06ae16c27cfe1d30394ab.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/75e1adce792fec7a46d5344ccb2abb1e.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/f9fa646b3369a44a230a111b0200bce3.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/045878d0b670d56137c565618bdc4797.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/1382bb4eec0b88b06abe9e651ff02746.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/c26837cc39e5fa6865d7709389bdeb43.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/42d124fea3431017fb13f228a68e9411.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/398b785d88544125b6627319ad7355aa.webp?x-oss-process=image/format,png)
![程序员,每个月给你发多少工资,你才会想老板想的事?](https://img-blog.csdnimg.cn/img_convert/1e59bc5240cdf101835d51da958f15e8.webp?x-oss-process=image/format,png)
714315943966)]
[外链图片转存中...(img-UZvc7LCf-1714315943966)]
[外链图片转存中...(img-jR05Oc8M-1714315943967)]
> **本文已被[CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】](https://bbs.csdn.net/topics/618154847)收录**
Java 洛谷 P1150 Peter的烟
最新推荐文章于 2024-05-31 10:46:10 发布