又又又一次遇到和Walter_Fang一样水的题了。
传送门
思想:很水的数学。我们可以发现,当且仅当剩余的人数%k为0时,第n个人才会被删去.所以每次删除减去要删去的人数,用while循环模拟一遍即可。
丑陋的码风:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,ans=1;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m;
while(n%m>0)ans++,n=n-(n/m);//n/m表示每次要删的人数
cout<<ans;
return 0;
}