17 多校
来源:互联网 发布:淘宝中待付款什么意思 编辑:程序博客网 时间:2024/05/29 16:27
KazaQ's Socks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 256 Accepted Submission(s): 171
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
题目链接:点击打开链接
题意: KazaQ有n双袜子,每次都在只剩一双袜子时把之前穿过的袜子给洗了,每双袜子都有自己的编号从1到n,每天穿所有干净的袜子中编号最小的一双。问第k天穿的袜子编号是多少。
找规律,带几个例子进去很快就找到规律了,前面n个为1、2、3、…、n,后面的循环周期就是(n-1)* 2 前n-1为1、2、3、…、n-2、n-1 ,后n-1为1、2、3、…、n-2、n 。
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;long long n,k,cas = 0;int main(){ while(~scanf("%lld%lld",&n,&k)) { if(k<=n) printf("Case #%lld: %lld\n",++cas,k); else { k -= n; if(k%(n-1)) printf("Case #%lld: %lld\n",++cas,k%(n-1)); else printf("Case #%lld: %lld\n",++cas,n-(k/(n-1)%2)); } } return 0;}
阅读全文
0 0
- 17 多校
- 17 多校
- 17 多校
- 17 多校
- 17 多校
- 17 多校
- 17 多校
- 17多校contest 1
- 17 多校 3
- 17 多校 3
- 17 多校 3
- 17 多校 3
- 17 多校 4
- 17 多校 4
- 17多校contest 6- 1003 Inversion ( 模拟
- 多校
- 多校
- 多校
- nginx 简要配置
- 多校1 A Add More Zero
- Shell笔记
- 编写提供程序数据外部接口的程序
- 数组中只出现一次的数字
- 17 多校
- HDOJ1004让气球飞吧
- uva 12108 Extraordinarily Tired Students
- TensorFlow之双隐含层多层感知器(MLP)
- Java-多线程概述
- c语言之电子通讯录
- unity UGUI 异步加载进度条
- 模拟实现string——增删查改
- 5.4 常用工具之HierarchyView介绍与快速入门