Problem Description
KazaQ wears socks everyday.

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.

 
Input
The input consists of multiple test cases. (about 2000)

For each case, there is a line contains two numbers n,k (2≤n≤109,1≤k≤1018).

 
Output
For each test case, output "Case #x: y" in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
 
Sample Input
3 7
3 6
4 9
 
Sample Output
Case #1: 3
Case #2: 1
Case #3: 2
 
Code:
#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的更多相关文章

  1. 【多校联合】(HDU6043)KazaQ's Socks

    [多校联合](HDU6043)KazaQ's Socks 一条纯粹的水题,记录下只是因为自己错的太多而已. 原因在于对数据的细节的把握不佳. 原题 KazaQ's Socks Time Limit: ...

  2. HDU6043 17多校1 KazaQ's Socks 水题

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6043 Problem Description KazaQ wears socks everyday. ...

  3. HDU 6043 KazaQ's Socks (规律)

    Description KazaQ wears socks everyday. At the beginning, he has nn pairs of socks numbered from 11  ...

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

  5. 杭电 KazaQ's Socks

    KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered from 1 to n in his cl ...

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

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

  8. 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,每天 ...

  9. KazaQ's Socks (找规律)

    #include<iostream> using namespace std; #define ll long long ll n, m; ll t; int main(){ while ...

随机推荐

  1. LINUX centos 7.2/7.3 搭建LANP环境

    首先我们先查看下centos的版本信息 #适用于所有的linux lsb_release -a #或者 cat /etc/redhat-release #又或者 rpm -q centos-relea ...

  2. response.sendRedirect页面跳转的方法总结——实习第六天

    今天想到要写这个博客完全是因为今天在这上面摔了一跤,同时也意识到了对于一个学Java的人来讲,知其然并且知其所以然是有多么的重要. 今天报了一个错误,讲的是空指针异常,原因就是在response.se ...

  3. html之改变图片透明度而不改变文字的透明度--两种方法实现

    图片与图片上的文字设置不同的透明度的两种方法: 第一种方法:背景图+定位+background: url(timg.jpg)no-repeat; <!DOCTYPE html> <h ...

  4. NoSQL数据库:Redis适用场景及产品定位

    传统MySQL+ Memcached架构遇到的问题 实际MySQL是适合进行海量数据存储的,通过Memcached将热点数据加载到cache,加速访问,很多公司都曾经使用过这样的架构,但随着业务数据量 ...

  5. 使用flask开发网站后端

    Flask 是一个用于 Python 的微型网络开发框架,可以用于快速的搭建一个小型的网站. 我的搜索引擎:http://www.abelkhan.com 就是基于flask开发 一个flask的He ...

  6. JavaScript面向对象轻松入门之多态(demo by ES5、ES6、TypeScript)

    多态(Polymorphism)按字面的意思就是"多种状态",同样的行为(方法)在不同对象上有不同的状态. 在OOP中很多地方都要用到多态的特性,比如同样是点击鼠标右键,点击快捷方 ...

  7. 安装GPU版本的tensorflow填过的那些坑!---CUDA说再见!

    那些坑,那些说不出的痛! --------回首安装的过程,真的是填了一个坑又出现了一坑的感觉.记录下了算是自己的笔记也能给需要的人提供一点帮助. 1 写在前面的话 其实在装GPU版本的tensorfl ...

  8. Hadoop出现的错误及处理

    1.local host is: (unknown); destination host is: "yun-ubuntu":8031; 原因:yun-ubuntu这个host 并不 ...

  9. voa 2015 / 4 / 13

    couch potato : someone who likes to spend a lot of time sitting or lying down while watching televis ...

  10. 基于JQ的单双日历,本人自己写的哈,还没封装,但是也能用

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>小 ...