A - Vasya and Socks

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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.

Sample Input

Input
2 2
Output
3
Input
9 3
Output
13

先上题意:vasya有n双袜子,土豪vasya每天穿一双,穿过的就扔掉,vasya的妈妈每m天给她买一双新的袜子,问vasya什么时候没有袜子穿。

附AC代码:

 #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std; int main(){
int n,m;
while(~scanf("%d %d",&n,&m)){
int i,ans=;
for(i=;n;i++){ if(i%m==){
n++;
}
n--;
}
printf("%d\n",i-);//此处注意减一 }
return ;
}

A - Vasya and Socks的更多相关文章

  1. CF460 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 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 ...

  3. 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 ...

  4. X - Vasya and Socks

    Problem description Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pai ...

  5. 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双袜子, ...

  6. codeforces 460A Vasya and Socks 解题报告

    题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...

  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. codeforcess水题100道

    之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...

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

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

随机推荐

  1. Linux 磁盘空间查询&&解决Linux 中“磁盘空间不足”的问题

    一.linux 查看目录的剩余空间大小 两个命令df .du结合比较直观 df -h 查看整台服务器的硬盘使用情况 du -lh --max-depth=1 : 查看当前目录下一级子文件和子目录占用的 ...

  2. windows下taskkill命令简介

    1.简介 使用该工具可以按照进程 ID (PID) 或映像名称终止任务. 2.语法 TASKKILL [/S system [/U username [/P [password]]]]        ...

  3. 取消CentOS 的图形界面 开机直接进入命令行模式(转)

    (1)具体操作   #vi /etc/inittab          –编辑/etc/inittab文件 找到下面语句: # Default runlevel. The runlevels used ...

  4. 编程算法 - 多重部分和问题 代码(C)

    多重部分和问题 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 有n种不同大小的数字a, 每种各m个. 推断能否够从这些数字之中选出若干使它们的 ...

  5. TFS 解除独占锁定

    cmd 进入Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE tf workspace /delete 工作区名;创建的用户 / ...

  6. Java中Class.forName()的作用(转载)

    http://www.360doc.com/content/10/0712/10/1720440_38421273.shtml# 使用jdbc方式连接数据库时会使用一句代码Class.forName( ...

  7. Hibernate的检索策略和优化

    一.检索策略概述 当我们实现了一对多或者多对多的映射后,在检索数据库时需要注意两个问题: 1.使用尽可能小的内存:当 Hibernate 从数据库中加载一个客户信息时, 如果同时加载所有关联这个客户的 ...

  8. 九度OJ 1090:路径打印 (树、DFS)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1704 解决:314 题目描述: 给你一串路径,譬如: a\b\c a\d\e b\cst d\ 你把这些路径中蕴含的目录结构给画出来,子目 ...

  9. 九度OJ 1103:二次方程计算器 (解方程)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2804 解决:633 题目描述: 设计一个二次方程计算器 输入: 每个案例是关于x的一个二次方程表达式,为了简单,每个系数都是整数形式. 输 ...

  10. imagemap的推荐使用方法,前端自适应image maps库

    1.map在浏览器的兼容性相对来说是比较好的,这是我在项目中的一个处理方法 推荐到下面网站去画map http://imagemap-generator.dariodomi.de/ 2.画完去gith ...