博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
10346 - Peter's Smokes
阅读量:6920 次
发布时间:2019-06-27

本文共 900 字,大约阅读时间需要 3 分钟。

Problem B

Peter’s Smokes

Input: standard input

Output: standard output

Time Limit: 4 seconds

Memory Limit: 32 MB

 

Peter has n cigarettes. He smokes them one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette.

How many cigarettes can Peter have?

Input

Input is a sequence of lines. Each line contains two integer numbers giving the values of n and k. The input is terminated by end of file.

Output

For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.

Sample Input

4 3
10 3
100 5

Sample Output

5
14
124
#include"stdio.h"int main(){  long n,k,s,m;//n为烟,m为烟头,k为换率,s为总数;    while(scanf("%ld%ld",&n,&k)!=EOF)   {s=0;    s+=n;    m=n;    while(m>=k)    {n=m/k;     s+=n;     m=m%k+n;     }      printf("%ld\n",s);     }return 0;}

 

 

转载于:https://www.cnblogs.com/www-xzpboke-com/archive/2013/02/23/2923413.html

你可能感兴趣的文章
Cron任务计划
查看>>
第一次开博客
查看>>
我的友情链接
查看>>
恶意扫描软件
查看>>
Java运行时环境JPEGImageWriter.writeImage函数整数溢出漏洞_
查看>>
九九乘法表
查看>>
Mac系统常用快捷键及技巧
查看>>
linux基础篇-17,find命令详解
查看>>
FastDFS分布式文件存储搭建
查看>>
autolay适配ios7以及iPhone4
查看>>
CentOS 7常用软件安装
查看>>
Linux(4)-03
查看>>
Memory Overcommitment in the ESX Server
查看>>
我的友情链接
查看>>
ads模式Samba服务器配置示例
查看>>
Android怎么打开和调用系统自带的程序示例(06)
查看>>
Exchange2013 SP1的详细安装及配置
查看>>
IOS中定时器NSTimer的开启与关闭以及怎样计算label的大小的方法
查看>>
将博客搬至CSDN
查看>>
浅 谈 Servlet
查看>>