Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
702 B
1
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, e;
    cin >> n >> k >> e;
    bool a[100001] = {0};
    int x = 1;
    int y = n;
    int dem = 0;
    while (y > 1)
    {
        if (!a[x])
        {
            dem++;
            if (dem % k == 0)
            {
                a[x] = true;
                y--;
            }
        }
        x++;
        if (x > n) x = 1;
    }

    while (a[x])
    {
        x++;
        if (x > n) x = 1;
    }
    cout << x << endl;
    if (e+1-x>n)
    {
        cout << (e + 1 - x-n) << endl;
    }
    else if (e+1-x<0) cout << (e+1-x+n)<<endl;
    else cout << e+1-x<<endl;

    return 0;
}
Leave a Comment