HDU6043 KazaQ's Socks
At the beginning, he has n pairs of socks numbered from 1 to n in his closets.
Every morning, he puts on a pair of socks which has the smallest number in the closets.
Every evening, he puts this pair of socks in the basket. If there are n−1 pairs of socks in the basket now, lazy KazaQ has to wash them. These socks will be put in the closets again in tomorrow evening.
KazaQ would like to know which pair of socks he should wear on the k-th day.
For each case, there is a line contains two numbers n,k (2≤n≤109,1≤k≤1018).
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h> using namespace std; int main()
{
long long int n,k,cnt=;
while(cin>>n>>k)
{
if(n>=k)
cout<<"Case #"<<cnt++<<": "<<k<<endl;
else
{
int a=(k-n)/(n-),b=(k-n)%(n-);
if(b!=)
cout<<"Case #"<<cnt++<<": "<<b<<endl;
else
{
if(a%==)
cout<<"Case #"<<cnt++<<": "<<n<<endl;
else
cout<<"Case #"<<cnt++<<": "<<n-<<endl;
}
}
}
return ;
}
HDU6043 KazaQ's Socks的更多相关文章
- 【多校联合】(HDU6043)KazaQ's Socks
[多校联合](HDU6043)KazaQ's Socks 一条纯粹的水题,记录下只是因为自己错的太多而已. 原因在于对数据的细节的把握不佳. 原题 KazaQ's Socks Time Limit: ...
- HDU6043 17多校1 KazaQ's Socks 水题
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6043 Problem Description KazaQ wears socks everyday. ...
- HDU 6043 KazaQ's Socks (规律)
Description KazaQ wears socks everyday. At the beginning, he has nn pairs of socks numbered from 11 ...
- 2017 Multi-University Training Contest - Team 1 1011&&HDU 6043 KazaQ's Socks【规律题,数学,水】
KazaQ's Socks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 杭电 KazaQ's Socks
KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered from 1 to n in his cl ...
- 2017ACM暑期多校联合训练 - Team 1 1011 HDU 6043 KazaQ's Socks (找规律)
题目链接 Problem Description KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbe ...
- 2017 Multi-University Training Contest - Team 1 KazaQ's Socks
Problem Description KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered f ...
- HDU 6043 - KazaQ's Socks | 2017 Multi-University Training Contest 1
/* HDU 6043 - KazaQ's Socks [ 找规律 ] | 2017 Multi-University Training Contest 1 题意: 一共 n 双袜子编号 1~n,每天 ...
- KazaQ's Socks (找规律)
#include<iostream> using namespace std; #define ll long long ll n, m; ll t; int main(){ while ...
随机推荐
- lvs之 lvs原理架构介绍
一. 概念 lvs的术语: Router:GWIP vs:virtual server,director rs:real server CIP:client IP VIP:virtual server ...
- JVM高级特性-三、垃圾收集之判断对象存活算法
一.概述 运行时数据区中,程序计数器.虚拟机栈.本地方法栈都是随线程而生随线程而灭的 因此,他们的内存分配和回收是确定的,在方法或线程结束时就回收.而Java堆和方 法区则是不确定的,程序运行过程中创 ...
- 批量自动更新SVN版本库 - Windows
开发过程中每天都要从SVN代码库里一个一个的update各个项目代码,不仅效率实在是低,也不符合程序员的"懒"精神,由于是在Windows环境做开发,自然就想到了使用bat来实现自 ...
- java 多线程访问同一个对象数据保护的问题
java 多线程同时访问统一个数据的时候,会引起一些错误,后面的线程会修改数据,而前面的线程还在使用修改前的内容, 使用 synchronized 关键字,保证代码块只能有一个线程来访问 public ...
- workerman启动失败解决
提示stream_socket_server(): unable to connect to tcp://0.0.0.0:2120 (Address already in use)php xxx.ph ...
- 在线SVN仓库实现:金山快盘+TortoiseSVN(Win)+SCPlugin(Mac)
前段时间一直在研究SVN在线托管,也尝试了网上推荐的免费托管网站. 但毕竟是是免费的,还是要受到比如空间大小.私有性等这样那样的限制,感觉有些麻烦. 而且,比较心疼自己在本地开发的时候积累的更新日志, ...
- 三、SolrCloud的搭建
本次安装是单台虚拟机安装,所以采用伪集群的方式进行安装,如果是真正的生产环境,将伪集群的ip改下就可以了,步骤是一样的. SolrCloud结构图如下: 环境准备: CentOS-6.4-i386-b ...
- peoplesoft function PSTREENODE 通过 deptid 获得部门树 全路径 code
create or replace function getUnitFullcode(deptid in varchar) return varchar2 is r ); c int; n ); m ...
- Newtonsoft.Json输出JSON 时动态忽略属性
一,前言 最近做项目采用Json形式和其他客户端交互,借助于Newtonsoft.Json . 由于业务场景不同,输出的Json内容也不同.要想忽略的属性,可以借助Newtonsoft.Json的特性 ...
- Spark Standalone Mode Configuration
For currently popular distributed framework Spark, here is the intro and step to configure the spark ...