X - Vasya and Socks
Problem description
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.
Examples
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.
解题思路:题目的意思就是Vasya每天穿一双袜子,当天晚上回家就扔掉这双袜子,而且第k*m天(k=1,2,...)母亲就会给她买一双袜子,求用完这些袜子一共需要多少天,水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
for(int i=;i<=n;++i)
if(i%m==)n++;
cout<<n<<endl;
return ;
}
X - Vasya and Socks的更多相关文章
- CF460 A. Vasya and Socks
A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 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 ...
- A - Vasya and Socks
A - Vasya and Socks Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64 ...
- Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)
题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second mem ...
- 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双袜子, ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
- Codeforces Round #262 (Div. 2) A B C
题目链接 A. Vasya and Socks time limit per test:2 secondsmemory limit per test:256 megabytesinput:standa ...
- codeforcess水题100道
之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...
- Codeforces Round #262 (Div. 2)解题报告
详见:http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2 1:A. Vasya and Socks http ...
随机推荐
- Python编码格式导致的csv读取错误
Python编码格式导致的csv读取错误(pandas.read_csv) 本文记录python小白我今天遇到的这两个问题(csv.reader和pandas.csv_read): pandas模块“ ...
- 如何在redhat 7上安装VNC服务器
平时我们基本上都是用xshell或者用putty远程我们的linux服务器,如果我们的linux服务器安装了图型化界面那我们又该如何远程使用我们的图形化界面呢?下面我们用vnc来实现远程我们的linu ...
- 198. House Robber(动态规划)
You are a professional robber planning to rob houses along a street. Each house has a certain amount ...
- jdk8--collect总结
https://blog.csdn.net/u014351782/article/details/53818430 一,collect是一个终端操作,它接收的参数是将流中的元素累积到汇总结果的各种方式 ...
- 优雅的退出/关闭/重启gunicorn进程
在工作中,会发现gunicorn启动的web服务,无论怎么使用kill -9 进程号都是无法杀死gunicorn,经过我一番百度和谷歌,发现想要删除gunicorn进程其实很简单. 第一步获取Guni ...
- 4、ceph-deploy之配置使用对象存储
从firefly(v0.80)版本开始,ceph存储显著的简化了安装和配置Ceph Object Gateway, Gateway进程嵌入到Civetweb,所以你需要安装一个web服务,或者配置Fa ...
- python在Linux中安装虚拟环境,区别python2和python3,分别安装模块
安装虚拟环境的时候遇到的问题,解决的过程很闹心,在这里简单直接的分享出来,就是为了解决问题. 安装虚拟环境(须在联网状态下) $ sudo pip install virtualenv $ sudo ...
- nyoj_71_独木舟上的旅行_201312122051
独木舟上的旅行 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 进行一次独木舟的旅行活动,独木舟可以在港口租到,并且之间没有区别.一条独木舟最多只能 ...
- Blue Jeans POJ 3080 寻找多个串的最长相同子串
Description The Genographic Project is a research partnership between IBM and The National Geographi ...
- 洛谷—— P2733 家的范围 Home on the Range
https://www.luogu.org/problem/show?pid=2733 题目背景 农民约翰在一片边长是N (2 <= N <= 250)英里的正方形牧场上放牧他的奶牛.(因 ...