【多校训练】hdu 6043 KazaQ's Socks
来源:互联网 发布:淘宝中心网页版登录 编辑:程序博客网 时间:2024/05/16 10:13
Problem Description
KazaQ wears socks everyday.
At the beginning, he hasn 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 aren−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 thek -th day.
At the beginning, he has
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
KazaQ would like to know which pair of socks he should wear on the
Input
The input consists of multiple test cases. (about 2000 )
For each case, there is a line contains two numbersn,k (2≤n≤109,1≤k≤1018) .
For each case, there is a line contains two numbers
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 73 64 9
Sample Output
Case #1: 3Case #2: 1Case #3: 2
题意:
有n双袜子1~n,每天早上选标号最小的一双。晚上发现只剩一双能穿时,就把之前的洗了,明晚就能穿。问第K天穿的是哪一个标号的袜子。
思路:
找规律发现,如果是n双袜子,有1~n-2的时候按顺序穿,只剩一双时奇数轮剩的是n-1,偶数轮剩的是n。
//// main.cpp// 1011//// Created by zc on 2017/7/25.// Copyright © 2017年 zc. All rights reserved.//#include <iostream>#include<cstdio>#include<cmath>#define ll long longusing namespace std;int main(int argc, const char * argv[]) { int kase=0; ll n,k; while(~scanf("%lld%lld",&n,&k)) { ll ans; if(k<=n) ans=k; else { k-=n+1; ll t1=k%(n-1); ll t2=k/(n-1); if(t1<=n-3) ans=t1+1; else ans=n-1+(t2&1); } printf("Case #%d: %lld\n",++kase,ans); } }
阅读全文
0 0
- 【多校训练】hdu 6043 KazaQ's Socks
- hdu-多校训练赛-KazaQ's Socks
- HDU 6043(2017 多校训练赛1 1011) KazaQ's Socks
- 2017 多校训练第一场 KazaQ's Socks
- HDU 6043 KazaQ's Socks
- hdu 6043 KazaQ's Socks
- HDU 6043 KazaQ's Socks
- HDU 6043 KazaQ's Socks
- HDU-KazaQ's Socks
- KazaQ's Socks HDU
- HDU 6043 KazaQ's Socks 找规律
- HDU 6043 KazaQ's Socks 【规律】
- HDU 6043 KazaQ's Socks(周期)
- HDU 6043 KazaQ's Socks【规律】
- HDU 6043 KazaQ's Socks(水~)
- (数学)HDU 6043 KazaQ's Socks
- hdu 6043 KazaQ's Socks(规律)
- HDU 6043(KazaQ's Socks) 规律题 Java
- SDUT-图的深度遍历
- Android6.0中申请权限在fragment中无回调
- ln 的使用
- lvalues and rvalues
- bzoj 3626: [LNOI2014]LCA(离线差分+树链剖分)
- 【多校训练】hdu 6043 KazaQ's Socks
- 第九章:django开发中发送邮件
- maven依赖本地非repository中的jar包
- Java知识:JVM内存模型的简单认识
- 大型网站架构模式
- MAC 搭建自动化测试环境(基于Appium+python+ios/android+unnitest+HTMLTestRunner)(一)
- oracle v$database 视图
- Pandas DataFrame 去重
- 23种设计模式之-抽象工厂模式