cigarettes

时间限制:3000 ms  |  内存限制:65535 KB
难度:2

描述

Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them

one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette. 
Now,do you know how many cigarettes can Tom has?

输入
First input is a single line,it's n and stands for there are n testdata.then there are n 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.
样例输入
3
4 3
10 3
100 5
#include<stdio.h>
int main()
{int n,a,b;int t1,t2,t3,k;scanf("%d",&n);while(n--){scanf("%d%d",&a,&b);t2=0;k=a;while(a/b>0){t1=a/b;t3=a%b;t2+=t1;//printf("t2==%d",t2);//
          a=t1+t3;} printf("%d\n",k+t2);}return 0;
}

转载于:https://www.cnblogs.com/zhaojiedi1992/archive/2012/08/02/zhaojiedi_2012_08_020000000.html

NYOJ94cigarettes相关推荐

最新文章

  1. 双表查询java代码_什么是JDBC?Java数据库连接性简介
  2. 适配器模式(Adapter)和外观模式(Facade)
  3. MPLS/×××分解:防止PE-CE的路由环路
  4. java8 lambda python_java8里面lambda的stream()用法讲解
  5. 2021 「营销云」攻略合集.pdf
  6. 『教程』Batch Normalization 层介绍
  7. MS SQL-Server快捷键
  8. 速成pytorch学习——2天
  9. outlook客户端接收邮件报错0x80040600
  10. java转换 HTML字符实体,java特殊字符转义字符串
  11. 检测客户端是否安装 Silverlight 插件和判断IE是否安装或支持Silverlight(限IE)
  12. wince6.0升级7.0系统_一个WINCC项目升级的案例分享
  13. 斯坦福大学深度学习公开课cs231n学习笔记(8)神经网络学习过程中的检查事项和参数调优
  14. 《用户故事地图》摘录
  15. iTunes历史各个版本下载地址
  16. On the Efficacy of Knowledge Distillation
  17. 安卓手机软件性能测试,手机性能评测软件
  18. 实用计算机相关日语词汇,日语分类词汇:计算机类(1)
  19. Java数据库连接池
  20. Linux的使用及软件安装

热门文章

  1. JS每日一题:new Vue()中发生了什么?
  2. 深入解读Service Mesh的数据面Envoy
  3. centos6.5安装mono
  4. 如何优雅的在Vue Project中使用vue-apollo
  5. sqoop关系型数据迁移原理以及map端内存为何不会爆掉窥探
  6. Ugly Number leetcode java
  7. [物理学与PDEs]第1章习题14 求解 rot 方程
  8. win03组策略-入门篇
  9. C++ 继承与组合的区别
  10. spring-mvc.xml与spring-mybatis.xml配置文件中命名空间问题