约瑟夫变种,直接套约瑟夫的话会TLE
#include <stdio.h>
int num, n;
int work(int n)
{
int t= 1073741824;
while ( n < t )
t>>=1;
return (n-t)*2+1;
}
int main()
{
while ( scanf("%de%d", &num, &n), num || n )
{
while ( n-- )
{
num*=10;
}
printf("%d\n", work(num));
}
return 0;
}