KazaQ's Socks HDU - 6043
2017-10-31 22:17
302 查看
KazaQ wears socks everyday. At the beginning, he has nn pairsof socks numbered from 11 to nn inhis 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−1n−1 pairsof 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 kk-thday.InputThe input consists of multiple test cases. (about 20002000) For each case, there is a line contains two numbers n,kn,k (2≤n≤109,1≤k≤1018)(2≤n≤109,1≤k≤1018).OutputFor each test case, output " Case #xx: yy"in one line (without quotes), where xx indicatesthe case number starting from 11 and yydenotesthe answer of corresponding case.Sample Input
3 7 3 6 4 9Sample Output
Case #1: 3 Case #2: 1 Case #3: 2
找规律 模拟
#include <stdio.h>typedef long long ll;int main() {ll n , k , m , m1 , m2;int Case = 1;while(~scanf("%lld%lld",&n,&k)) {if(k <= n) m = k;else {m = k - n;m1 = m/(n-1);m2 = m%(n-1);if(m2) {if(m1%2) {m = m2;}else{if(m2 == n-1) m = n;else m = m2;}}else {if(m1%2) m = n-1;else m = n;}}printf("Case #%d: %d\n",Case++,m);}return 0;}
相关文章推荐
- 2017杭电多校联赛 1011 KazaQ's Socks HDU 6043
- ACM刷题之hdu————KazaQ's Socks
- hdu 6043 KazaQ's Socks 模拟
- HDU 6043(2017 多校训练赛1 1011) KazaQ's Socks
- HDU 6043 KazaQ's Socks【规律】
- HDU 6043 KazaQ's Socks
- HDU 6043(KazaQ's Socks) 规律题 Java
- 17暑假多校联赛1.11 HDU 6043 KazaQ's Socks
- HDU 6043 KazaQ's Socks 找规律
- HDU 6043 KazaQ's Socks 【规律】
- 【HDU】6043 - KazaQ's Socks(思维)
- (数学)HDU 6043 KazaQ's Socks
- 2017 Multi-University Training Contest - Team 1:KazaQ's Socks(hdu 6043)
- HDU 6043 KazaQ's Socks(水~)
- 2017杭电多校联赛 1011 KazaQ's Socks(找规律)HDU 6043
- HDU 6043 KazaQ's Socks - 2017多校联盟1 第11题 -规律
- HDU 6043 KazaQ's Socks
- HDU 6043 KazaQ's Socks(暑期训练1011)
- 【多校训练】hdu 6043 KazaQ's Socks
- 17 多校 - 1 - 1011 - KazaQ's Socks (HDU 6043)