博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SDUST 2844-Mineral Water(数学)
阅读量:6580 次
发布时间:2019-06-24

本文共 1517 字,大约阅读时间需要 5 分钟。

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.

演示样例输入

22 25 4

演示样例输出

36
貌似山东某届的省赛题?也是够水的了
题意 :n瓶水,m个空瓶能够换一瓶水。问最多能够喝多少瓶水。
注意用LL 然后没什么了。先喝掉m的整数倍。然后剩下的n%m瓶加上能够换到水的瓶数,这时候把这个数看成最開始那个n就能够了。循环搞定。

 
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long longusing 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;}

转载地址:http://monno.baihongyu.com/

你可能感兴趣的文章
css3 animate 和关键帧 @-webkit-keyframes
查看>>
文字链接颜色设置
查看>>
图片转流
查看>>
ubunto应用软件
查看>>
HTML 标签说明
查看>>
锋利的jQuery-2--判断jQuery获取到的对象是否存在$().length
查看>>
linux 查询系统版本命令、查询端口号是否被占用命令
查看>>
java笔记八:IO流之字符流与字符缓冲流
查看>>
Docker 命令收集
查看>>
myeclipse注册码生成器
查看>>
怎样快速学好PHP技术之PHP学习方法总结
查看>>
iOS App间相互跳转漫谈 part2
查看>>
Java CAS 原理剖析
查看>>
ISCC2014 writeup
查看>>
Kotlin 知识梳理(1) Kotlin 基础
查看>>
js正则表达式
查看>>
iOS socket通信,编解码,浮点型数据解析
查看>>
手把手教你如何新建scrapy爬虫框架的第一个项目(下)
查看>>
前端基础15:JS作用域基础
查看>>
Linux系统相关命令
查看>>