Computer Programming Contest Preparation

ToolBox - Source for: 118/11805/a.c



/home/toolbox/public_html/solutions/118/11805/a.c
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <sys/types.h>
    4 #include <sys/stat.h>
    5 #include <fcntl.h>
    6 #include <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2021-12-5
   21  * Purpose: fun
   22  * Problem: 11805 - Bafana Bafana
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 int numberOfTimes;
   30 int n;
   31 int k;
   32 int p;
   33 
   34 void init()
   35 {
   36     /* FUNCTION init */
   37     scanf("%d ", &numberOfTimes);
   38 } /* FUNCTION init */
   39 
   40 void dump()
   41 {
   42     /* FUNCTION dump */
   43 } /* FUNCTION dump */
   44 
   45 void getInput()
   46 {
   47     /* FUNCTION getInput */
   48     scanf(" %d %d %d ", &n, &k, &p);
   49 } /* FUNCTION getInput */
   50 
   51 void process()
   52 {
   53     /* FUNCTION process */
   54     p = p % n; /* get rid of cycles */
   55     k = k + p;
   56     if (k > n)
   57         {
   58             k = k - n;
   59         }
   60     printf("%d\n", k);
   61 } /* FUNCTION process */
   62 
   63 int main()
   64 {
   65     /* main */
   66     int i;
   67 
   68     init();
   69     for (i=1; i<=numberOfTimes; i++)
   70         {
   71             /* while */
   72             getInput();
   73             printf("Case %d: ", i);
   74             process();
   75         } /* while */
   76 
   77     return EXIT_SUCCESS;
   78 } /* main */
   79 
   80