NYOJ 题目94 cigarettes

题目描述:

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大致意思是假设汤姆有n支香烟,每吸k支香烟就会得到一支新的香烟,求汤姆最多能吸多少支香烟?

#include<stdio.h>
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
int n,k,i;
int sum=0;
scanf("%d %d",&n,&k);
for(i=1;i<=n;i++)
{
sum=sum+1;
if(sum%k==0)
n=n+1;
}
printf("%d",sum);
printf("\n");
}
}

//AC

欢迎各路大神评论!

 

时间: 2024-10-16 04:47:07

NYOJ 题目94 cigarettes的相关文章

nyoj 94 cigarettes 【水题】

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

NYOJ题目57 6174问题

----------------------------------------------------- 感觉这个OJ题目难度划分很不合理,这道理明明很简单却给了2的难度,而之前难度为0的水题有好多难死个人没做出来让我暗暗觉得自己脑子里都是屎... 把题目描述翻译成人话的意思就是多少次以后这个序列会出现,想明白这一点就比较简单了. AC代码: 1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main

NYOJ题目1049自增自减

--------------------------------- 简单的字符判断. AC代码: 1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 int times=Integer.parseInt(sc.nextLine()); 10 while(times-->0

NYOJ题目10505C?5S?

--------------------------------------- 水. AC代码: 1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 int times=sc.nextInt(); 10 while(times-->0){ 11 double a=sc.n

NYOJ 题目56 阶乘式因式分解(一)

题目描述: 给定两个数m,n,其中m是一个素数. 将n(0<=n<=10000)的阶乘分解质因数,求其中有多少个m. 输入 第一行是一个整数s(0<s<=100),表示测试数据的组数随后的s行, 每行有两个整数n,m. 输出 输出m的个数. 样例输入 2 100 5 16 2 样例输出 24 15我的代码://AC #include<stdio.h>int main(){ int s,k; scanf("%d",&s); while(s--)

NYOJ题目28大数阶乘

-------------------------------------祭出BigInteger AC代码: import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); BigInteger ans=fac(n);

NYOJ题目124中位数

------------------------------------- 排序取中间数即可 AC代码: 1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(String[] args) { 7 8 Scanner sc=new Scanner(System.in); 9 10 int times=sc.nextInt(); 11 wh

NYOJ题目168房间安排

------------------------------------------------ 其实就是计算一下时间线上重叠部分的最大值是多少 一个很容易想到的办法就是模拟,如下 AC代码: 1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 int times=sc.

NYOJ题目125盗梦空间

----------------------------------------- 开始的时候打算每进入或退出一层就换算成那层的时间,然而WA了. 怒,干脆就来点暴力的,管你什么跟什么只要停留了就根据层次统一换算成现实时间,使用BigDecimal保证精度,AC. AC代码: 1 import java.math.BigDecimal; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(