SDUST 2844-Mineral Water(数学)

Mineral Water

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

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
貌似山东某届的省赛题?也是够水的了
题意 :n瓶水,m个空瓶可以换一瓶水,问最多可以喝多少瓶水。
注意用LL 然后没什么了,先喝掉m的整数倍,然后剩下的n%m瓶加上可以换到水的瓶数,这时候把这个数看成最开始那个n就可以了,循环搞定。
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
	ll n,m;int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld",&n,&m);
		ll ans=0;
		while(n>=m)
		{
			ans+=(n-n%m);
			ll tem=n/m;
			n%=m;
			n+=tem;
		}
		ans+=n;
		printf("%lld\n",ans);
	}
    return 0;
}

时间: 2024-07-28 23:30:21

SDUST 2844-Mineral Water(数学)的相关文章

2019ACM-ICPC沈阳网络赛-C-Dawn-K&#39;s water(完全背包模板题)

Dawn-K's water  1000ms 262144K Dawn-K recently discovered a very magical phenomenon in the supermarket of Northeastern University: The large package is not necessarily more expensive than the small package. On this day, Dawn-K came to the supermarket

C:Dawn-K&#39;s water (The Preliminary Contest for ICPC Asia Shenyang 2019)

Dawn-K recently discovered a very magical phenomenon in the supermarket of Northeastern University: The large package is not necessarily more expensive than the small package. On this day, Dawn-K came to the supermarket to buy mineral water, he found

words2

餐具:coffee pot 咖啡壶coffee cup 咖啡杯paper towel 纸巾napkin 餐巾table cloth 桌布tea -pot 茶壶tea set 茶具tea tray 茶盘caddy 茶罐dish 碟plate 盘saucer 小碟子rice bowl 饭碗chopsticks 筷子soup spoon 汤匙knife 餐刀cup 杯子glass 玻璃杯mug 马克杯picnic lunch 便当fruit plate 水果盘toothpick 牙签中餐:bear's

#Memcached系列#(6)使用Enyim.Caching访问Memcached的一个C#控制台程序

这篇文章主要是通过Enyim.Caching来完成访问Memcached. 这篇文章标为"原创",其实,是从多个地方整合过来的内容:但觉得"转载"也不合适,也并不是完全照搬别人的东西. 参考网址(不过,感觉它的配置写的乱糟糟的):http://www.cnblogs.com/luyinghuai/archive/2008/08/28/1278200.html (1)首先下载EnyimMemcached(文件名:EnyimMemcached-master.zip).

python 自然语言处理(四)____词典资源

词典或者词典资源是一个词和/或短语及其相关信息的集合,例如:词性和词意定义等相关信息.词典资源附属于文本,而且通常在文本的基础上创建和丰富.下面列举几种nltk中的词典资源. 1. 词汇列表语料库 nltk中包括了一些仅仅包含词汇列表的语料库.词汇语料库是UNIX中的/usr/dict/words文件,被一些拼写检查程序所使用.我们可以用它来寻找文本语料中不常见的或拼写错误的词汇. 1)过滤词汇 1 >>> def unusual_words(text): 2 ... text_voca

How could you Demand Beachfront with not a Beachfront Case

Summer months, for people like us, suggests the sun's rays, beachfront, brazilian bikini and many others. For anyone who is intending to enjoy the fun for the beachfront, people might as well choose eye-catching beachfront case. The item besides real

SPMHomework1

A project that I have recently completed was  a virtual-reality Android game named "Where the Miaomiao is" which was an Innovation project of University Students. There were five people in the project and I was one of the members. Based on the v

Hotel Check in &amp; check out

Check in: EP01: I want to check in. I have a reservation. I am here to check in. Here is my ID. Here is  my passport. Here is my credit card. Should I fill out a form. Can I see the room first. Could you take me to see the room. I'm sorry. I am not c

CNPC海外操作人员英语日常用语900句

一.Greetings 问候语1. Hello! / Hi! 你好!2. Good morning / afternoon / evening! 早晨(下午/晚上)好!3. I’m Kathy King. 我是凯西•金.4. Are you Peter Smith? 你是彼得•史密斯吗?5. Yes, I am. / No, I’m not. 是,我是./ 不,我不是.6. How are you? 你好吗?7. Fine, thanks. And you? 很好,谢谢,你呢?8. I’m fi