Advertisement
tastypear

约瑟夫环最后一位

Nov 17th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.16 KB | None | 0 0
  1. int f(int n, int m)
  2. {
  3.     int i, r = 0;
  4.     for (i = 2; i <= n; i++)
  5.         r = (r + m) % i;
  6.     return r+1;
  7. }
  8.  
  9. 约瑟夫环高端解法……but why?……
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement