题目链接: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
  1. 2 2
output
  1. 3
input
  1. 9 3
output
  1. 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.

代码例如以下:

  1. //#pragma warning (disable:4786)
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <string>
  6. #include <cstdlib>
  7. #include <climits>
  8. #include <ctype.h>
  9. #include <queue>
  10. #include <stack>
  11. #include <vector>
  12. #include <utility>
  13. #include <deque>
  14. #include <set>
  15. #include <map>
  16. #include <iostream>
  17. #include <algorithm>
  18. using namespace std;
  19. const double eps = 1e-9;
  20. #define INF 1e18
  21. //typedef long long LL;
  22. //typedef __int64 LL;
  23. int main()
  24. {
  25. int n, m;
  26. while(~scanf("%d%d",&n,&m))
  27. {
  28. int i, j;
  29. int sum = 0;
  30. int tt = 0;
  31. for(i = n,j = 1; i > 0; j++,i--)
  32. {
  33. if(j%m == 0)
  34. i++;
  35. sum++;
  36. }
  37. printf("%d\n",sum);
  38. }
  39. return 0;
  40. }

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. idea 无法创建Scala class 选项解决办法汇总

    原因一:没有添加scala sdk 解决:file=>project structure =>Global Libraries,添加scala-sdk: 没有scala sdk的可以去网上 ...

  2. NYOJ 469 擅长排列的小明 II

    擅长排列的小明 II 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 小明十分聪明,而且十分擅长排列计算. 有一天小明心血来潮想考考你,他给了你一个正整数n,序列1, ...

  3. 【Luogu】P1417烹调方案(排序01背包)

    题目链接 对食材进行排序,重载运算符代码如下: struct food{ long long a,b,c; bool operator <(const food &a)const{ re ...

  4. 刷题总结——魔术球问题(ssoj最小路径覆盖+网络流)

    题目: 题目描述 假设有 n 根柱子,现要按下述规则在这 n 根柱子中依次放入编号为 1,2 ,3,… 的球.(1)每次只能在某根柱子的最上面放球.(2)在同一根柱子中,任何 2 个相邻球的编号之和为 ...

  5. 常州模拟赛d6t3 噪音

    FJ有M个牛棚,编号1至M,刚开始所有牛棚都是空的.FJ有N头牛,编号1至N,这N头牛按照编号从小到大依次排队走进牛棚,每一天只有一头奶牛走进牛棚.第i头奶牛选择走进第p[i]个牛棚.由于奶牛是群体动 ...

  6. 转载: 找不到MSVCR90.dll、Debug vs Release及cppLapack相关

    今天调试程序时出现了,找不到MSCVR90.dll的错误,最好查找到了解决办法,原文链接如下:   http://hi.baidu.com/wpzhao/blog/item/72dc08f77ce9b ...

  7. Java线程池快速学习教程

    1. Java线程池 线程池:顾名思义,用一个池子装载多个线程,使用池子去管理多个线程. 问题来源:应用大量通过new Thread()方法创建执行时间短的线程,较大的消耗系统资源并且系统的响应速度变 ...

  8. ElasticSearch分词器

    什么是分词器? 分词器,是将用户输入的一段文本,分析成符合逻辑的一种工具.到目前为止呢,分词器没有办法做到完全的符合人们的要求.和我们有关的分词器有英文的和中文的.英文的分词器过程:输入文本-关键词切 ...

  9. springboot收集

    Spring Boot实战:拦截器与过滤器 参考:https://blog.csdn.net/m0_37106742/article/details/64438892 https://www.ibm. ...

  10. R语言入门视频笔记--2--一些简单的命令

    一.对象 1.列举当前内存中的对象 ls() 2.删除不需要的对象 rm(某对象名称) 3.查看向量长度 length(某向量名称) 4.查看向量类型 mode(某向量名称) 二.函数 1.seq函数 ...