#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b void vprint(T &V){ for(auto v : V){ cout << v << " "; } cout << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N, K; cin >> N >> K; ll a; // me ll b; // opponent for(;;){ // second attack if(N % (K+1) == 0){ p(0); cin >> b; if(b>=N){ return 0; } N -= b; } a = N % (K+1); p(a); } return 0; }