Official

A - Last Card Editorial by en_translator


If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.


If \(N\) is large enough, then the answer is \(A+K-1\). Actually no people has the index of \(N+1\) or more, so we have to find the remainder divided by \(N\). Also note that there is no person with index \(0\).

Sample code (C++)

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k, a; cin >> n >> k >> a;
    int ans = (a + k - 1) % n;
    if(ans == 0) ans = n;
    cout << ans << endl;
}

posted:
last update: