A - Vasya and Socks
A - Vasya and SocksTime 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
Input2 2Output3Input9 3Output13
先上题意: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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- POCO类
我认为POCO(简单传统CLR对象)重点应该是简单,不跟其他不相关的类进行关联关系或不相关的属性.<NHibernate 4 Beginner Guid>这本书有提到,应该是满足下面三个条 ...
- ubuntu14.04下CPU的caffe配置,不成功的朋友请与我(lee)联系,后面附带邮箱
因广大朋友需求cpu的caffe配置.所以我(lee)在这份博客中对cpu配置caffe做出对应操作说明.希望能够解决大家对cpu配置caffe的困惑.少走弯路. 假设有安装不成功的朋友能够和我联系, ...
- 【HDOJ 5654】 xiaoxin and his watermelon candy(离线+树状数组)
pid=5654">[HDOJ 5654] xiaoxin and his watermelon candy(离线+树状数组) xiaoxin and his watermelon c ...
- Oracle oledb 打包并集成到程序安装包(VC ADO訪问Oracle)
近期有一个项目和oracle交互,我用的是ADO的方式进行试问操作. 首先把数据库连接的东东记录一下,老了记性不好啊! 操作例如以下: //连接串这么写的话就能够不用配置 tnsnames.ora配置 ...
- Django-缓存的配置
缓存的介绍 在动态网站中,用户所有的请求,服务器都会去数据库中进行相应的增,删,查,改,渲染模板,执行业务逻辑,最后生成用户看到的页面. 当一个网站的用户访问量很大的时候,每一次的的后台操作,都会消耗 ...
- LeetCode:判断最长前缀
之前一直忽略了一个问题就是:给定的空字符串数组 char* longestCommonPrefix(char** strs, int strsSize) { char* result; if(strs ...
- 自动添加QQ
自动添加QQ <meta http-equiv="refresh" content="0; url=tencent://AddContact/?fromId=50& ...
- RYU改动监听port Mininet在custom自建拓扑和连接到指定控制器命令解释
1.RYU控制器改动监听port 在ryu/ryu/ofproto以下的ofproto_common.py watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc ...
- session.use_cookies有什么作用,
session.use_cookies有什么作用, @ini_set('session.use_cookies', 1);什么意思 若session.use_cookies = 1 sessionid ...
- g++: command not found的解决
G++没有装或却没有更新 以下方法都可以试试: centos: yum -y update gcc yum -y install gcc+ gcc-c++ ubuntu: apt-get up ...