【多校联合】(HDU6043)KazaQ's Socks
【多校联合】(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;
}
【多校联合】(HDU6043)KazaQ's Socks的更多相关文章
- HDU6043 KazaQ's Socks
Problem Description KazaQ wears socks everyday. At the beginning, he has n pairs of socks numbered f ...
- HDU6043 17多校1 KazaQ's Socks 水题
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6043 Problem Description KazaQ wears socks everyday. ...
- 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 ...
- 2016暑假多校联合---Rikka with Sequence (线段树)
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...
- 2016暑假多校联合---Windows 10
2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...
- 2016暑假多校联合---Substring(后缀数组)
2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...
- 2016暑假多校联合---To My Girlfriend
2016暑假多校联合---To My Girlfriend Problem Description Dear Guo I never forget the moment I met with you. ...
- 2016暑假多校联合---A Simple Chess
2016暑假多校联合---A Simple Chess Problem Description There is a n×m board, a chess want to go to the po ...
- HDU 5792---2016暑假多校联合---World is Exploding
2016暑假多校联合---World is Exploding Problem Description Given a sequence A with length n,count how many ...
随机推荐
- 使用ToDateTime方法转换日期显示格式
实现效果: 知识运用: Convert类的ToDateTime方法:(将字符串转化为DateTime对象) public static DateTime ToDateTime(string value ...
- 【Elasticsearch】搜索小记之 match VS match_phrase
最近稍微研究了一下ElasticSearch(下文简称ES),所谓可扩展的开源弹性搜索解决方案,跟同事笑称,如果它作为SQL SERVER的话,我的了解还在基本的select语句上,当然学习它也是一个 ...
- on-session问题
.D:\0kecheng\bos\bosv2.0_chapter03.无条件查询. 方法1.@JSON(serialize=false)是注解排除不需要加载的实体类上,找到它的get方法,解决no-s ...
- focal loss和retinanet
这个是自己用的focal loss的代码和公式推导:https://github.com/zimenglan-sysu-512/Focal-Loss 这个是有retinanet:https://git ...
- 【luogu P4137 Rmq Problem / mex】 题解
题目链接:https://www.luogu.org/problemnew/show/P4137 求区间内最大没出现过的自然数 在add时要先判断会不会对当前答案产生影响,如果有就去找下一个答案. # ...
- lucene&solr学习——分词器
下图是语汇单元的生成过程: 从一个Reader字符流开始,创建基于Reader的Tokenizer分词器,经过三个TokenFilter生成语汇单元Tokens. 要看分词器的分析效果,只需要看Tok ...
- papers-06-02
午睡被同事吵醒,只好干活.看到微信公众号有一篇文章说老朋友呢,点进去发现原来相关的工作好多,而且好新好细致. 微信的文章可以见这里: 探究最陌生的老朋友Softmax 里面的几篇文章可以看看. Lar ...
- HTML中id和class选择器
<1>.id和class的区别? id相当于人的身份证不可以重复 class相当于人的名称可以重复 一个HTML标签只能绑定一个id名称 一个HTML标签可以绑定多个class名称 < ...
- 数据库查询服务DBCacheServer
各个业务系统,都需要查询各类数据库; 一般查询数据库都是客户端自己连接,根据现在的情况,存在以下几点问题 1.客户端连接很多,连接大小,峰值不可控 2.客户端SQL程序员自己写,参差不齐 3.SQL书 ...
- ABAP术语-IDOC
IDOC 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/21/1075988.html Intermediate Document Inte ...