poj 2509 Peter's smokes
http://poj.org/problem?id=2509
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 16957 | Accepted: 6984 |
Description
How many cigarettes can Peter have?
Input
Output
Sample Input
4 3
10 3
100 5
Sample Output
5
14
124
Source
#include<stdio.h>
int main()
{
int a,b;
while(~scanf("%d%d",&a,&b))
{
int sum = a;
while(a >= b)
{
sum += a/b;
a = a/b + a%b;
}
printf("%d\n",sum);
}
return ;
}
poj 2509 Peter's smokes的更多相关文章
- POJ 2509 Peter's smokes(Peter的香烟)
POJ 2509 Peter的香烟 描述 Peter抽烟.他抽烟一个个地抽着烟头.从 k (k>1) 个烟头中,他可以抽一根新烟.彼得可以抽几支烟? 输入 输入是一系列行.每行包含两个给出n和k ...
- Peter's smokes -poj 2509
题意:彼得有n支雪茄,每k个烟头可以换一支新雪茄,问彼得最多可以吸多少支雪茄 ? 当时自己做时,错在了直接在while循环开始前,便将雪茄的初始数量给加上了,然而应该是先处理后再加上最终剩余的雪茄数量 ...
- UVa 10346 - Peter's Smokes
题目大意:Peter有n支烟,每k个剩下的烟头可以卷成一支新烟,问Peter能吸多少跟烟? 简单数学题. #include <cstdio> int main() { #ifdef LOC ...
- POJ 2509
#include <iostream> #include <stdio.h> using namespace std; int main() { //freopen(" ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ解题经验交流
感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理. 题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...
- 算法之路 level 01 problem set
2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- Zerojudge解题经验交流
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...
随机推荐
- Nginx return 关键字配置小技巧
Nginx的return关键字属于HttpRewriteModule模块: 语法:return http状态码 默认值:无 上下文:server,location,if 该指令将结束执行直接返回htt ...
- BLE GATT规范中关于UUID与属性的详细解析
1. 角色 除了GAP定义了角色之外,BLE还定义了另外2种角色:GATT服务器和GATT客户端,它们完全独立于GAP的角色.提供数据的设备称为GATT服务器,访问GATT服务器而获得数据的设备称为G ...
- linux OSlab4 添加自定义系统调用
http://blog.csdn.net/ly01kongjian/article/details/8947285 http://www.cnblogs.com/hoys/archive/2011/0 ...
- Qt通过QToolTip显示浮动信息
QToolTip类的应用十分简单,其QToolTip类中全都是静态方法,如果要显示浮动信息的话使用该函数即可: void QToolTip::showText ( const QPoint & ...
- Top 10 Free Wireless Network hacking/monitoring tools for ethical hackers and businesses
There are lots of free tools available online to get easy access to the WiFi networks intended to he ...
- iOS面试题 02
在面试的时候,面试官问我,“你对内存管理了解的多吗?” 我忘了当时是怎么回答的了,但是,肯定是一时没想起来怎么回答. 1.谁创建谁释放 2.autoreleasepool 3.retain,copy, ...
- asp.net操作xml
下面是xml文档内容: <content width="368" height="450" bgcolor="cccccc" load ...
- MSP430之频率测量,误差1Hz
#include "timerHz.h" #include "msp430g2553.h" #define _DEBUG_TIMERHZ_ unsigned ] ...
- http://blog.csdn.net/littlechang/article/details/8642149
http://blog.csdn.net/littlechang/article/details/8642149
- Python处理时间 time && datetime 模块
Python处理时间 time && datetime 模块 个人整理,获取时间方式: import datetime import time #获取当前时间:Thu Nov 03 ...