HDU 2017多校联赛-1011 KazaQ's Socks
2017-07-25 18:07
393 查看
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 73 6
4 9
Sample Output
Case #1: 3Case #2: 1
Case #3: 2
水水水
#include<iostream> using namespace std; int main() { long long int a,b,c,d,e; a=0; while(cin>>b>>c) { a++; if(c<=b) { cout<<"Case #"<<a<<": "<<c<<endl; continue; } c=c-b; d=int(c/(b-1)); e=c%(b-1); if(e==0) { if(d%2==0) cout<<"Case #"<<a<<": "<<b<<endl; else cout<<"Case #"<<a<<": "<<b-1<<endl; } else cout<<"Case #"<<a<<": "<<e<<endl; } return 0; }
相关文章推荐
- HDU 6043(2017 多校训练赛1 1011) KazaQ's Socks
- 2017杭电多校联赛 1011 KazaQ's Socks(找规律)HDU 6043
- HDU 6043 KazaQ's Socks - 2017多校联盟1 第11题 -规律
- HDU 2017 多校联赛 1011 KazaQ's Socks
- 2017杭电多校联赛 1011 KazaQ's Socks HDU 6043
- 17 多校 - 1 - 1011 - KazaQ's Socks (HDU 6043)
- HDU 2017多校联赛-Is Derek lying?
- HDU 2017 多校联赛2 1003 Maximum Sequence
- HDU6075 Questionnaire(思路,2017 HDU多校联赛 第4场)
- HDU6168 Numbers(模拟,2017 HDU多校联赛 第9场)
- HDU 2017 多校联赛2 1001 Is Derek lying?
- HDU6098 Inversion(RMQ,2017 HDU多校联赛 第6场)
- HDU 6053 TrickGCD+6055 Regular polygon【2017多校联赛2】
- HDU 2017 多校联合训练赛2 1011 6055 Regular polygon map&pair
- HDU 2017 多校联赛3 1011 RXD's date
- HDU-2017 多校训练赛8-1011-Killer Names
- HDU 6127 Hard challenge+HDU 6129 Just do it【2017多校联赛】
- hdu 6143: Killer Names (2017 多校第八场 1011)
- 2017杭电多校联赛-KazaQ's Socks 找规律
- HDU 2017 多校联赛 1002 Balala Power!