题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6043

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
 
题意:这个人每天早上会从柜子拿一双序号最小的袜子,晚上扔进脏衣篓。 他会等到干净的袜子只剩一双的时候才去洗脏衣篓的袜子,给你袜子的总数n和第几天k,问你第k天穿的袜子序号为几。
题解:可以通过分析n=3和n=4的情况来推断,打括号的说明是一起洗的。
          n=3:(1 2)( 3 1 )(2 1)( 3 1)( 2 1)( 3 1).....
          n=4:  (1 2 3) (4 1 2) (3 1 2) (4 1 2) (3 1 2) (4 1 2) (3 1 2)......
          除去第一个括号,每一个括号的开头都是仅剩的最后一双袜子,然后会从上一括号中洗好的再选(0~n-2)双,所以就有了这样的规律。
 
 #include<iostream>
#include<cstdio> using namespace std; int main()
{
int t=;
long long n,k,res;
while(~scanf("%lld%lld",&n,&k))
{
if(k<=n)
{
res=k;
}
else
{
k-=n;
int q=k%(n-);
if(q==)
if(k/(n-)%==)
res=n;
else
res=n-;
else
res=q;
}
printf("Case #%d: %lld\n",t++,res);
}
return ;
}

HDU6043 17多校1 KazaQ's Socks 水题的更多相关文章

  1. 17 多校1 Add More Zero 水题

    Problem Description There is a youngster known for amateur propositions concerning several mathemati ...

  2. HDU 6140 17多校8 Hybrid Crystals(思维题)

    题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...

  3. 2019浙大校赛--E--Potion(签到水题)

    一丢丢思维就ok 题目大意: 魔法师要煮药,有n个等级的药,所需要的药物为a1,a2...an,意为第n级需要多少药物,下一行为库存的不同等级药物,药物可降级使用不可升级. 思路:从高级药物开始解,把 ...

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

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

  5. HDU6043 KazaQ's Socks

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

  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. HDU 6043 KazaQ's Socks (规律)

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

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

  9. 杭电 KazaQ's Socks

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

随机推荐

  1. React Native之FlexBox布局

    参考原文链接:https://www.cnblogs.com/wujy/p/5841685.html 弹性盒模型(The Flexible Box Module),又叫Flexbox,意为“弹性布局” ...

  2. Leetcode 993. 二叉树的堂兄弟节点

    993. 二叉树的堂兄弟节点  显示英文描述 我的提交返回竞赛   用户通过次数195 用户尝试次数229 通过次数195 提交次数462 题目难度Easy 在二叉树中,根节点位于深度 0 处,每个深 ...

  3. Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇

    1. dataguard主备切换   1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,appl ...

  4. 十五、MVC的WEB框架(Structs2)

    一.Structs标签 与JSTL标签库类似,Structs2也有专属标签库 常见的标签有:from,iterator,check,radio,select 1.form标签 用于提交数据 <% ...

  5. ssl tls 证书链 根证书和叶证书查询

    你基本上需要做的是构建一个证书链,如果你没有得到它作为一个链.证书链基本上由第零个位置的最终实体证书(也是叶证书,链中最重要的证书)组成,其次是次要证书. CA证书是最不重要的. 所以这是通常的X.5 ...

  6. npm node sass 安装报错

    报错为 不能找到python2.7,记得曾经已经安装过python,结果npm install cnpm install npm install node-sass 各种不行,结果在cmd 输入pyt ...

  7. std::string find 的返回值

    std::string  的方法 find,返回值类型是std::string::size_type, 对应的是查找对象在字符串中的位置(从0开始), 如果未查找到,该返回值是一个很大的数据(4294 ...

  8. CAD(镜像对象)(镜像后的微调)(门窗标注)5.14

    由于绘制的cad图形整体是对称的,所以先画了一半,然后再镜像过去.沿着某一对称轴. 注意:1.有些三维内容在二维是选择不上的.2.对称轴上的柱子和墙体之类的不能选中.把轴网和标注的图层锁起来.冻结起来 ...

  9. 尚学堂java 答案解析 第五章

    本答案为本人个人编辑,仅供参考,如果读者发现,请私信本人或在下方评论,提醒本人修改 一.选择题 1.AB 解析:A可以被所有类访问,B可以被当前包的所有类访问,也可以被所有子类访问 2.A 解析:所有 ...

  10. js中有哪几种函数?

    匿名函数,回调函数,递归函数,构造函数