Mineral Water

题目描述
Laoshan mineral water is one of famous well-known mineral water, Tyrant(means”Tu Hao”) Chierush liked to drink this mineral water very much. He said that it is such a natural taste, but this is not the focus. One day Chierush went to the campus supermarket to buy n bottles of Laoshan mineral water, the boss see that he is an acquaintance, so he gave him a copy of preferential policies - he can change every m empty bottles into one bottle mineral water. Your task is to help Chierush calculate how many bottles of mineral water he can drink?
输入
The input consists of multiple test cases. The first line contains an integer T means the number of test cases. Each test case consists of one line with two numbers represent n and m. (T<=100, 2<=n,m<=2*10^9)
输出
For each test case, output one line, including one number that represents the answer.
示例输入
2
2 2
5 4
示例输出
3

6

#include<stdio.h>
#include<string.h>
int main()
{
    //freopen("b.txt","r",stdin);
    long long a,b,t;
    while(scanf("%lld",&t)==1)
    {
		while(t--)
		{
			scanf("%lld %lld",&a,&b);
			long long sum=a;
			while(a/b)
			{
				sum+=a/b;
				a=a/b+a%b;
				
			}
			printf("%lld\n",sum);
		}
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值