【多校联合】(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 ...
随机推荐
- jmeter报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"的解决方法
1.报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supporte ...
- Oracle连接问题
ORA-01034: ORACLE not availableORA-27101: shared memory realm does not exist sqlplus /nolog conn /as ...
- 【luogu P1004 方格取数】 题解
题目链接:https://www.luogu.org/problemnew/show/P1004 标准的DP,不明白为什么有普及+提高的难度 四维DP[i][j][k][l] 表示第一遍走到i,j格子 ...
- notepad++括号自动补全插件: XBracket Lite
1.4.5.1. 通过XBracket Lite实现括号的自动补全 先去打开相应的设置: 再根据自己的需要去设置: 其中解释一下相应的选项的含义: Treat'' as brackets 把单引号', ...
- Node.js 笔记01
一.Node.js 前言 1.node.js 之父 Ryan Dahl(瑞安达尔) ,技术好,颜值高! 数学系博士, 中途退学, 为了生活, 学习了Ruby On Rails接Web项目, 经过两年成 ...
- Python基础—16-网络编程
网络编程 相关概念 OSI七层模型:开放系统互连参考模型.它从低到高分别是:物理层.数据链路层.网络层.传输层.会话层.表示层和应用层. TCP/IP:在OSI七层模型的基础上简化抽象出来的一套网络协 ...
- 【例题收藏】◇例题·6◇ 电压机制(voltage)
◆例题·6◆ 电压机制 周六日常模拟赛……已经不知道该说什么了(感觉做不出来的都是好题) ▷ 题目 (终于不用自己翻译英文题了╮(╯-╰)╭) [问题描述] 科学家在“无限神机”(Infinity M ...
- springMVC-RESTful约束下dispatcher拦截对象优化
警告: No mapping found for HTTP request with URI [/management/fonts/glyphicons-halflings-regular.woff] ...
- MySQL备份恢复之mydumper
Preface In my previous two blogs,we have known about the tool of backing up MySQL db.I'm gon ...
- python核心编程2 第十三章 练习
13-3.对类进行定制.写一个类,用来将浮点型值转换为金额. class MoneyFmt(object): def __init__(self, value=0.0, flag='-'): self ...