You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
501 B
C++
29 lines
501 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
long long n, k, t = 0, ans;
|
|
while (~scanf("%lld%lld", &n, &k))
|
|
{
|
|
if (k <= n)
|
|
ans = k;
|
|
else
|
|
{
|
|
k -= n--;
|
|
ans = k % n;
|
|
if (ans == 0)
|
|
ans = n + 1 - ((k / n) & 1);
|
|
}
|
|
printf("Case #%lld: %lld\n", ++t, ans);
|
|
}
|
|
return 0;
|
|
}
|
|
/*
|
|
* 1 2 3
|
|
* 1 2 1 3
|
|
* 1 2 1 3
|
|
1 2 3 4 5 6 7
|
|
1 2 3 4 5 6 1 2 3 4 5 7
|
|
1 2 3 4 5 6 1 2 3 4 5 7
|
|
|
|
*/ |