题目链接:http://codeforces.com/contest/460/problem/A

A. Vasya and Socks
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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?

Input

The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100),
separated by a space.

Output

Print a single integer — the answer to the problem.

Sample test(s)
input
2 2
output
3
input
9 3
output
13
Note

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.

代码例如以下:

//#pragma warning (disable:4786)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <deque>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
#define INF 1e18
//typedef long long LL;
//typedef __int64 LL;
int main()
{
int n, m;
while(~scanf("%d%d",&n,&m))
{
int i, j;
int sum = 0;
int tt = 0;
for(i = n,j = 1; i > 0; j++,i--)
{
if(j%m == 0)
i++;
sum++;
}
printf("%d\n",sum);
}
return 0;
}

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)的更多相关文章

  1. Codeforces Round #262 (Div. 2) A. Vasya and Socks【暴力/模拟/袜子在可以在合法情况下增加后用几天】

    A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子, ...

  3. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  4. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  5. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  6. Codeforces Round #262 (Div. 2)解题报告

    详见:http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2 1:A. Vasya and Socks   http ...

  7. Codeforces Round #262 (Div. 2) A B C

    题目链接 A. Vasya and Socks time limit per test:2 secondsmemory limit per test:256 megabytesinput:standa ...

  8. Codeforces Round #262 (Div. 2) 题解

    A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

随机推荐

  1. Django深入----django.db.transaction

    django 的事务: transaction.py atomic---原子性 def atomic(using=None, savepoint=True): # Bare decorator: @a ...

  2. TOJ 1203: Number Sequence

    1203: Number Sequence Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByte Total Submi ...

  3. 【Luogu】P1607庙会班车Fair Shuttle(线段树+贪心)

    我不会做贪心题啊……贪心题啊……题啊……啊…… 我真TM菜爆了啊…… 这题就像凌乱的yyy一样,把终点排序,终点相同的按起点排序.然后维护一个查询最大值的线段树.对于一个区间[l,r],如果这个区间已 ...

  4. BZOJ3996 [TJOI2015]线性代数 【最小割】

    题目 给出一个NN的矩阵B和一个1N的矩阵C.求出一个1*N的01矩阵A.使得 D=(AB-C)A^T最大.其中A^T为A的转置.输出D 输入格式 第一行输入一个整数N,接下来N行输入B矩阵,第i行第 ...

  5. #ifdef endif 用法

    "#ifdef 语句1 程序2 #endif“ 可翻译为:如果宏定义了语句1则程序2. 作用:我们可以用它区隔一些与特定头文件.程序库和其他文件版本有关的代码. 代码举例:新建define. ...

  6. concurrentHashMap面试题

    面试题: ConcurrentHashMap有哪些构造函数? ConcurrentHashMap使用什么技术来保证线程安全? ConcurrentHashMap的get方法是否要加锁,为什么? Con ...

  7. bzoj2286 (sdoi2011)消耗战(虚树)

    [Sdoi2011]消耗战 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 4052  Solved: 1463[Submit][Status][Dis ...

  8. mongodb的安装及环境配置

    一 下载 官网:https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.3-signed.msi 官网可能打不开, ...

  9. vue elementUI 表单校验(数组多层嵌套)

    在使用vue element-ui form表单渲染的时候,会遇到这样的数据结构: { "title":''123455, "email":'123456@qq ...

  10. js-判断当前页面是否在微信浏览器中打开

    方案一:推荐 var ua = navigator.userAgent.toLowerCase(); var isWinxin = ua.indexOf('micromessenger') != -1 ...