SDUST 2844-Mineral Water(数学)
来源:互联网 发布:手机淘宝怎么联系旺旺 编辑:程序博客网 时间:2024/04/28 06:45
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 <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 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;}
2 0
- SDUST 2844-Mineral Water(数学)
- Mineral Water
- [换汽水]sdut 2844 Mineral Water
- sdust 2681 求个最大值 (数学+思维)
- sdust 实验
- leetcode:数学:Water and Jug Problem(365)
- Sdust ACM Weekly #5
- sdust练习题-切蛋糕
- SDUST练习题-IP地址
- SDUST第三次作业
- SDUST 第二次实验
- SDUST 第四次实验
- SDUST 第四次作业
- SDUST 实验+ 作业
- poj 3185 The Water Bowls(数学:高斯消元)
- 数学 ( 卡特兰数 )——Scoop water ( CSU 1320 )
- Water
- WATER
- 简单算法的常用网站
- 1410231608-hd-Rightmost Digit
- 第九周项目五:程序填充题(1)
- 菜鸟nginx源码剖析数据结构篇(三) 单向链表 ngx_list_t
- jQuery之父:坚持每天都要写代码
- SDUST 2844-Mineral Water(数学)
- rpmbuild 制作rpm包
- App反编译二次打包常见问题处理
- 第九周 重要技能体验 单步执行
- RecyclerView and CardView
- 时间进度管理-甘特图
- 第9周项目3 输出星号图(1)
- C#实验上机
- Java和SQL型的默认映射