---
title: 4C 圓圈遊戲
tags: solution
---
# C. 圓圈遊戲
### Jospher Problem
```cpp=
int findTheWinner(int n, int k) {
if (n <= 1)
return 0 ;
else
return (findTheWinner(n - 1, k) + k ) % n ;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
freopen("2.out","w",stdout);
int n, k, test ;
cin >> test ;
for ( int i = 0 ; i < test ; i ++ ) {
cin >> n >> k ;
int ans = findTheWinner( n, k )+1 ;
cout << ans << endl ;
}
}
```