fzu 1150 Farmer Bill's Problem
2016-05-11 15:09
232 查看
Problem 1150 Farmer Bill's Problem
Accept: 877 Submit: 1805
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 is a sequence of lines. Each line contains two integer numbers giving the values of n and k.
For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.
4 3
10 3
100 5
5
14
124
题意:
跟空瓶子换汽水一样,k个烟头换1个香烟
Accept: 877 Submit: 1805
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
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.
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 310 3
100 5
Sample Output
514
124
题意:
跟空瓶子换汽水一样,k个烟头换1个香烟
#include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define INF 0x3f3f3f using namespace std; int main(){ int n,k,t,s; while(~scanf("%d%d",&n,&k)){ s=n; while(n>=k){ t=n/k; s+=n/k; n=n%k; n+=t; } printf("%d\n",s); } return 0; }
相关文章推荐
- 【C#设计模式-访问者模式】
- IOS开发-UIView之动画效果的实现方法(合集)
- 跟开涛老师学shiro -- INI配置
- iOS 检查更新
- BZOJ4584 : [Apio2016]赛艇
- github上获取开源软件(如wireshark,Cimage等)源代码的方法
- Sorry, you can’t enroll at this time
- PAT (Basic Level) Practise (中文)1040. 有几个PAT(25)
- 在LinearLayout中,巧妙使用weightSum和layout_weight
- Java 设计模式(十三) 接口隔离原则(ISP)
- 多线程05:《疯狂Java讲义》学习笔记——线程同步
- 模拟实现通讯录 <一><静态方法>
- c语言基础巩固 2:完全平方
- Python黑客编程2 入门demo--zip暴力破解
- redis命令全集(自用)
- 【转】Android的WebView控件载入网页显示速度慢的究极解决方案
- 一致性Hash算法在Redis分布式中的使用
- 机器学习记录一
- 【算法作业】 循环赛问题 分治算法
- 【原创】swarm源码分析(3)---manage cluster