Computer Programming Contest Preparation

ToolBox - Source for: 115/11547/a.c



/home/toolbox/public_html/solutions/115/11547/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 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 /* fprintf(stderr, "functionName: message", varslist); */
   16 
   17 /*
   18  *  Author:
   19  *    Date:
   20  * Purpose:
   21  * Problem:
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 int num;
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34     scanf("%d ", &numberOfTimes);
   35 } /* FUNCTION init */
   36 
   37 void dump()
   38 {
   39     /* FUNCTION dump */
   40 } /* FUNCTION dump */
   41 
   42 void getInput()
   43 {
   44     /* FUNCTION getInput */
   45     scanf(" %d ", &num);
   46 } /* FUNCTION getInput */
   47 
   48 void process()
   49 {
   50     /* FUNCTION process */
   51     /*
   52       num = ((((((num * 567) / 9) + 7492) * 235) / 47) - 498);
   53       num = (num * 3015) + 37460 - 498;
   54       num = num * 3015 + 36962;
   55       num = (num % 100) / 10;
   56     */
   57     num = (((num * 63) + 7492) * 5) - 498;
   58     if (0 > num)
   59         {
   60             num = -num;
   61         }
   62     num = (num / 10) % 10;
   63     printf("%d\n", num);
   64 } /* FUNCTION process */
   65 
   66 int main()
   67 {
   68     /* main */
   69     int i;
   70 
   71     init();
   72     for (i=0; i<numberOfTimes; i++)
   73         {
   74             /* while */
   75             getInput();
   76             process();
   77         } /* while */
   78 
   79     return EXIT_SUCCESS;
   80 } /* main */
   81 
   82