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 ...
 
随机推荐
- cocos2d-x项目101次相遇:在HelloWorld上--建立新场景
			
cocos2d-x 101次相遇 / 文件夹 1 安装和环境搭建 -xcode 2 Scenes , Director, Layers, Sprites 3 建立图片菜单 4 在 ...
 - C# trim split dataGrid
			
C#中Trim().TrimStart().TrimEnd()的用法: 这三个方法用于删除字符串头尾出现的某些字符.Trim()删除字符串头部及尾部出现的空格,删除的过程为从外到内,直到碰到一 ...
 - 如何将安卓手机中已安装的应用导出一个apk安装包
			
首先安装ES文件浏览器 然后应用里找到你要导出apk的应用,长按应用,备份应用, 然后在upbacks/apps文件夹里找吧 不得不说 ES浏览器还是屌啊
 - Ecilpse绑定jdk的源码
			
因为近期才入职,所以电脑环境才配好,今天在写代码的时候,想查看源码,发现不能查看,所以在网上百度了一下: 下面是解决方法: 1.在Ecilpse的窗体下,点击Preferences 2.然后点击Jav ...
 - java通过http方式下载文件
			
package com.qiyi; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...
 - centos 在CentOS下编译FFmpeg
			
所需软件 准备 yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel -y 新版还 ...
 - cURL实现Get和Post
			
1.Get请求: //初始化 $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, "http://www.jb51.n ...
 - php 面向对象的三大要素(封装、继承、多态)以及重写(override)和重载(overload)的举例说明
			
PHP是一种HTML内嵌式的,用来制作动态网页的服务器端的脚本语言.其特点是:开发周期短,稳定安全,简单易学,免费开源,良好的跨平台特性.PHP是一种面向对象的程序设计语言,目前已成为全球最受欢迎的五 ...
 - 九度OJ 1129:Skew数 (大数运算)
			
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:734 解决:548 题目描述: 在 skew binary表示中, 第 k 位的值xk表示xk*(2k+1-1). 每个位上的可能数字是0 ...
 - please add a 'mainClass’ property
			
when build an spring project with this command: mvn spring-boot:run there will may show an error mes ...