Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
754 B
2
Indexable
Never
#include <bits/stdc++.h>
#define maxn 1002

using namespace std;


int n, a[maxn], k, s, y;
int main(){
    cin >> n >> s >> k;

    for ( int i = 1; i <= n; i++)
        a[i] = 0;

    int ktra = 0; int dem = 0; int done = 0;
    while ( ktra == 0 )
    {
       for ( int i = 1; i <= n ; i++ )
            if ( a[i] == 0 )
            {
                dem ++;
                if ( dem == s ) { a[i] = 1; dem = 0; done ++; }
            }
        if ( done == n - 1 ) ktra = 1;
    }

    for ( int i = 1; i <= n; i++)
        if ( a[i] == 0 ) { cout << i << endl; y = i; }
    while ( y != 1)
    {
        k = k + 1; y = y + 1;
        if ( k > n ) k = k - n;
        if ( y > n ) y = y - n;
    }
    cout << k;
}
Leave a Comment