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
题意:自己看看吧,很简单
解法:
1 理解题意后,知道应该是找循环节,于是写了1 2 3 和 1 2 3 4发现是1 2,1 3和1 2 3,1 2 4这样顺序
2 然后分情况讨论
 #include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
const int maxn=2e5+;
int main(){
long long n,k;
long long num=;
while(cin>>n>>k){
printf("Case #%lld: ",num++);
if(k<=n){
cout<<k<<endl;
}else{
k-=n;
long long pos=k/(n-);
long long ans=k%(n-);
if(ans){
cout<<ans<<endl;
}else{
if(pos%){
cout<<n-<<endl;
}else{
cout<<n<<endl;
}
}
}
}
return ;
}

最新文章

  1. JQuery 滚动条插件perfect-scrollbar
  2. linux配置本地源
  3. Google地图实现
  4. Object.prototype.toString.call()进行类型判断
  5. 【CQgame】[下一百层] [Down]
  6. MySQL表类型和存储引擎版本不一致解决方法
  7. 转:简单的RTSP消息交互过程
  8. 电赛初探(一)&mdash;&mdash;正弦波、方波、锯齿波转换
  9. android ListView进阶
  10. Java &amp; XML Tool Overview
  11. OS X平台上MySQL环境搭建
  12. tyvj P1864 [Poetize I]守卫者的挑战(DP+概率)
  13. [Effective C++系列]-透彻了解inlining的里里外外
  14. magento产品批量导出导入
  15. python 数据驱动(ddt)
  16. ODI Scenario 场景
  17. docker被屏蔽后下载方法
  18. dedecms批量删除文档关键词可以吗
  19. SQL Fundamentals: 表的创建和管理(表的基本操作,闪回技术flashback,表结构修改)
  20. PHP获得用户的真实IP地址

热门文章

  1. Gym - 101147E E. Jumping —— bfs
  2. CNN卷积神经网络_深度残差网络 ResNet——解决神经网络过深反而引起误差增加的根本问题,Highway NetWork 则允许保留一定比例的原始输入 x。(这种思想在inception模型也有,例如卷积是concat并行,而不是串行)这样前面一层的信息,有一定比例可以不经过矩阵乘法和非线性变换,直接传输到下一层,仿佛一条信息高速公路,因此得名Highway Network
  3. 【应用】SVG动态 时钟
  4. javaScrpit中NaN的秘密
  5. 组合优化学习笔记&lt;之&gt;从贪心算法到子集系统再到拟阵
  6. Asterisk func group
  7. Oracle数据库当前连接数、最大连接数的查询与设置
  8. HDU2586(LCA应用:在带权树中求任意两点之间的距离)
  9. aidl笔记 2/5/2015
  10. NLP | 自然语言处理 - 语言模型(Language Modeling)