#include <iostream>
using namespace std;
int josephus(int n, int m)
{
if(n == 1) return 0;
else return ( josephus(n-1,m)+m ) % n;
}
int main()
{
int n, m;
cin >> n >> m;
int result = josephus(n, m);
cout << result+1 << endl;
}
约瑟夫环递归
最新推荐文章于 2024-06-18 19:23:54 发布