题解 | #删数#
删数
http://www.nowcoder.com/practice/f9533a71aada4f35867008be22be5b6e
//递推公式:f[1] = 0 ,f[n] = (f[n - 1] + K) mod n //如果想了解:http://blog.csdn.net/taoyanqi8932/article/details/52335719
#include <stdio.h>
int lastNum(int n)
{
int res=0;
for (int i=2;i<=n;i++)
res=(res+3)%i;
return res;
}
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
int m;
m=lastNum(n);
printf("%d\n",m);
}
return 0;
}