【多校联合】(HDU6043)KazaQ’s Socks

一条纯粹的水题,记录下只是因为自己错的太多而已。

原因在于对数据的细节的把握不佳。

原题

KazaQ’s Socks

  • Time Limit: 2000/1000 MS (Java/Others)
  • Memory Limit: 131072/131072 K (Java/Others)

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

代码

#include <iostream>
#include <bits/stdc++.h>
using namespace std; typedef long long ll; int main()
{
ll n,k,kase=0;
while(cin>>n>>k)
{
cout<<"Case #"<<++kase<<": ";
if(k>n)
{
k-=n;
int flag=(k/(n-1)+1)%2;
if(flag)
cout<<int(k%(n-1)==0?n:k%(n-1))<<endl;
else cout<<int(k%(n-1)==0?n-1:k%(n-1))<<endl;
}
else cout<<k<<endl;
}
return 0;
}

Original Address

【多校联合】(HDU6043)KazaQ's Socks的更多相关文章

  1. HDU6043 KazaQ's Socks

    Problem Description KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered f ...

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

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

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

  4. 2016暑假多校联合---Rikka with Sequence (线段树)

    2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...

  5. 2016暑假多校联合---Windows 10

    2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...

  6. 2016暑假多校联合---Substring(后缀数组)

    2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...

  7. 2016暑假多校联合---To My Girlfriend

    2016暑假多校联合---To My Girlfriend Problem Description Dear Guo I never forget the moment I met with you. ...

  8. 2016暑假多校联合---A Simple Chess

    2016暑假多校联合---A Simple Chess   Problem Description There is a n×m board, a chess want to go to the po ...

  9. HDU 5792---2016暑假多校联合---World is Exploding

    2016暑假多校联合---World is Exploding Problem Description Given a sequence A with length n,count how many ...

随机推荐

  1. PS中会使用到的快捷键有那些?

    P.S:我刚刚在百度上,搜了一些关于PS的快捷键的使用. 我把它总结了一下.对我今后的P图有所帮助. PS的所有快捷键 1. 显示/隐藏选择区域 [Ctrl]+[H] 2. 取消当前命令:Esc: 工 ...

  2. Codeforces Round #515 (Div. 3) B. Heaters【 贪心 区间合并细节 】

    任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limi ...

  3. 一个有意思的标签<marquee>

    marquee标签不是HTML3.2的一部分,并且只支持MSIE3以后内核,所以如果你使用非IE内核浏览器(如:Netscape)可能无法看到下面一些很有意思的效果,该标签是个容器标签.  一.mar ...

  4. 【洛谷P3469】[POI2008]BLO-Blockade

    BLO-Blockade 题目链接 若一个点为割点:统计出每个子树的大小,两两相乘再相加, 再加上n-1,为这个点与其他点的拜访数, 因为拜访是互相的,最后再乘二即可 若一个点不是割点:只有(n-1) ...

  5. 【题解】洛谷P1731 [NOI1999] 生日蛋糕(搜索+剪枝)

    洛谷P1731:https://www.luogu.org/problemnew/show/P1731 思路 三重剪枝 当前表面积+下一层表面积如果超过最优值就退出 当前体积+下一层体积如果超过总体积 ...

  6. 到底什么时候需要使用 final

    final: final修饰属性,则该属性不可再次改变,而且在初始化中必须在属性或者是构造方法中其中且中有一个中初始化他 final修饰方法,则该方法不可被重写 final修饰类,则不可被继承 1:当 ...

  7. oracle 的分页查询与mysql 的分页查询

    oracle 的分页查询: select * from (select o.*,rownum rn  from Persons o) where rn >40 and rn <=60 : ...

  8. 自定义组件v-model的实质性理解

    用了几个月Vue一直很纠结自定义组件的v-model实现,最近开始学习React时,React中受控组件与状态提升的理念与v-model不谋而合. 转载请注明地址: https://www.cnblo ...

  9. MySql基本数据类型及约束

    1. 常用的数据类型(data_type) 字符串类型 CHAR(n) : 固定长度 VARCHAR(n) : 可变长度 NCHAR(n) : 使用utf8存储,固定长度 NVARCHAR(n) : ...

  10. BZOJ2580: [Usaco2012 Jan]Video Game(AC自动机)

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 159  Solved: 110[Submit][Status][Discuss] Descriptio ...