描述

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
样例输出
5
14
124
 import java.util.Arrays;
import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int T;
int n;
int k;
int count;
int temp; T=scanner.nextInt(); while(true){
if(T==0)
break;
T--; n=scanner.nextInt();
k=scanner.nextInt(); count=0;
temp=n;
while(true){
if(n>=k){
n=n-k+1;
count++;
}
else
break;
}
System.out.println(count+temp);
}
}
}
 

cigarettes的更多相关文章

  1. ACM cigarettes

    cigarettes 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has many cigarettes. We hypothesized that he ...

  2. nyoj 94-cigarettes (分清楚,那一部分的cigarettes是用过的,那一部分是没有用过的)

    94-cigarettes 内存限制:64MB 时间限制:3000ms 特判: No 通过数:13 提交数:20 难度:2 题目描述: Tom has many cigarettes. We hypo ...

  3. NYOJ_94 cigarettes 递归VS迭代

    题目地址 分析: 英文题事实上看懂意思和正常的也都差点儿相同.就算有几个单词不认识也无伤大雅. 一共同拥有n支烟,每天抽k支. 每抽完k支,会得到一仅仅. a组数据.  输入n k的个数.输出一共抽了 ...

  4. 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)

    第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...

  5. 转载 Appstore 上传被拒原因及解释

    原 apps被拒绝的各种理由以及翻译 1. Terms and conditions(法律与条款) 2. Functionality(功能) 3. Metadata (name, descriptio ...

  6. high-frequency words and phases

    abide by(=be faithful to ; obey vt)忠于:遵守. a) Plese feel assured we will abide by our promise. 2. be ...

  7. 编写高质量代码改善C#程序的157个建议[为泛型指定初始值、使用委托声明、使用Lambda替代方法和匿名方法]

    前言 泛型并不是C#语言一开始就带有的特性,而是在FCL2.0之后实现的新功能.基于泛型,我们得以将类型参数化,以便更大范围地进行代码复用.同时,它减少了泛型类及泛型方法中的转型,确保了类型安全.委托 ...

  8. smoke

    1.Have a smoke? 2.Would you like a cigarette? 3.Cigarettes? 4.Let's go have a smoke. 5.Do  you smoke ...

  9. poj 2509 Peter's smokes

    http://poj.org/problem?id=2509 Peter's smokes Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

随机推荐

  1. 导出Excel Gridview

    /// <summary>    /// 定义导出Excel的函数    /// </summary>    /// <param name="FileType ...

  2. Samsung Galaxy S II GT-I9100 指令全集 部分指令请慎用

    英文版 谷歌翻译 Obtain/Change Device Information *#06# (Display IMEI number) *#1234# (Display current firmw ...

  3. HDU 4670 Cube number on a tree

    divide and conquer on tree. #include <map> #include <vector> #include <cstdio> #in ...

  4. 学习总结(annotation)

    自定义MyAnnotationTest package com.zhanghaobo.annotation; import java.lang.annotation.ElementType; impo ...

  5. android手机ping不通linux的ip地址

    我的linux是装载虚拟机里的,修改虚拟机的网络连接方式为桥接模式即可.

  6. (1) css的核心基础

     css的核心基础 1.css的基本语法在具体使用css之前,请各位兄弟姐妹先思考一个生活中的问题,一般情况下我们是如何描述一个人的呢? 小明{ 民族:汉族: 性格:温柔: 性别:男: 体重:68kg ...

  7. 详解MyEclipse10 安装Spket 1.6.23(支持Extjs4.1.1及jQuery1.8)

    用MyEclipse10安装Spket主要有3种方式:在线下载更新.下载Zip覆盖.下载jar包安装.我用在线安装尝试了N次终于还是失败,只好下载jar包来安装,在失败了M次之后终于安装成功,现在网上 ...

  8. VPS之openVPN的安装配置

    原文地址:http://www.blogjava.net/dongbule/archive/2010/11/01/336714.html 上次写的<VPS的购买和使用>中提到了openVP ...

  9. HITAG 2 125kHz RFID IC Read-Write 256 bits

    Features 256 bits EEPROM memory organized in 8 pages of 32 bits each 32 bits unique factory programm ...

  10. Uva592 Island of Logic

      题意:神人鬼三个种族,神只说真话,鬼只说假话,人白天说真话,晚上说假话.根据对话内容区分种族和白天黑夜.  最多有A, B, C, D, E五个人 算法:枚举A, B, C, D, E的种族情况和 ...