UVa: 11805 (Bafana Bafana)



// link: http://uva.onlinejudge.org/external/118/11805.html
// runtime: 0.022s
// tag: math, ad-hoc

#include <cstdio>

using namespace std;

int main() {

    int testCases;

    scanf ("%d", &testCases);

    int cases = 0;

    while ( testCases-- ) {

        int n, k, p;

        scanf ("%d %d %d", &n, &k, &p);

        while (p--) {

            k++;

            if (k > n) k = 1;

        }

        printf ("Case %d: %d\n", ++cases, k);
    }

    return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s