【Codeforces Round 262 (Div 2)A】【水题】Vasya and Socks 妈妈买袜子 最多穿几天
来源:互联网 发布:位置虚拟定位软件 编辑:程序博客网 时间:2024/06/11 17:23
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?
The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.
Print a single integer — the answer to the problem.
2 2
3
9 3
13
In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.
In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
#include<stdio.h>#include<iostream>#include<string.h>#include<string>#include<ctype.h>#include<math.h>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;int n, m;int main(){while (~scanf("%d%d", &n, &m)){for (int i = 1; ;++i){if (--n < 0){printf("%d\n", i - 1);break;}if (i%m == 0)++n;}}return 0;}
- 【Codeforces Round 262 (Div 2)A】【水题】Vasya and Socks 妈妈买袜子 最多穿几天
- Codeforces Round #262 (Div. 2) A. Vasya and Socks
- Codeforces #262 (Div. 2) A. Vasya and Socks(水题)
- Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)
- Codeforces 460A Vasya and Socks(水题)
- Codeforces A. Vasya and Socks
- Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
- Codeforces Round #281 (Div. 2) A. Vasya and Football
- Codeforces Round #281 (Div. 2) A - Vasya and Football
- codeforces-#460A Vasya and Socks
- CodeForces-460A-Vasya And Socks
- Codeforces Vasya and Socks
- A. Vasya and Socks
- A. Vasya and Socks
- Codeforces Round #206 (Div. 1) A. Vasya and Robot
- Problem--460A--Codeforces--A. Vasya and Socks
- Codeforces Round #403 (Div. 2) A. Andryusha and Socks(简单模拟)
- Codeforces Round #206 (Div. 2) C - Vasya and Robot
- 文章标题
- uva 1103 紫书例题6-13(dfs)
- 【CROC 2016 - Elimination RoundE】【DP】Intellectual Inquiry 长度为m字符串后添加n位最大本质不同子串个数
- 【gdx ashley】入门
- 射线与长方体
- 【Codeforces Round 262 (Div 2)A】【水题】Vasya and Socks 妈妈买袜子 最多穿几天
- 使用XLSTransformer生成报表的步骤和流程
- 【Codeforces Round 262 (Div 2)B】【暴力枚举】Little Dima and Equation b乘数位之和的a次方+c=数字
- 第一次使用Markdown在线编译器写博客
- nyoj--284 坦克大战(bfs+优先队列)
- 【Codeforces Round 262 (Div 2)C】【二分】浇花使得最小的尽可能大
- POJ 1010 题目翻译+题解
- 【Codeforces Round 262 (Div 2)D】【构造】Little Victor and Set 集合最多取k数使得异或值尽可能小
- 【Codeforces Round 262 (Div 2)E】【爆搜 估价函数剪枝 搜索步长剪枝】Roland and Rose 整格放点 点对欧几里得距离平方和尽可能大