标签:rect ane mil eve name etc inline 开始 names
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
3 7 3 6 4 9Sample Output
Case #1: 3 Case #2: 1 Case #3: 2
#include <iostream> #include <algorithm> #include <map> #include <cstdio> using namespace std; int which(long long n,long long k) { if(k<=n)return k; k-=n;//规律 int d=k%(n-1); int c=k/(n-1); if(d)return d; return n-(c%2); } int main() { long long n,k; int i=1,d; while(cin>>n>>k) { d=which(n,k); printf("Case #%d: %d\n",i,d); i++; } }
标签:rect ane mil eve name etc inline 开始 names
原文地址:http://www.cnblogs.com/8023spz/p/7498951.html