Computer Programming Contest Preparation

ToolBox - Source for: 109/10970/a.c



/home/toolbox/public_html/solutions/109/10970/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 <stdint.h>
    7 #include <math.h>
    8 #include <stdlib.h>
    9 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 #define MAX_LINE 257
   16 
   17 /*
   18  *  Author: Isaac Traxler
   19  *    Date: 2015-03-09
   20  * Purpose:
   21  * Problem: 10970
   22  */
   23 
   24 /*
   25  * This template reads lines of data at a time until end of file.
   26  */
   27 
   28 int m;
   29 int n;
   30 
   31 void init()
   32 {
   33     /* FUNCTION init */
   34 } /* FUNCTION init */
   35 
   36 void dump()
   37 {
   38     /* FUNCTION dump */
   39 } /* FUNCTION dump */
   40 
   41 int getInput()
   42 {
   43     /* FUNCTION getInput */
   44     int dataReadFlag;
   45 
   46     dataReadFlag = 2 == scanf(" %d %d ", &m, &n);
   47     return (dataReadFlag);
   48 } /* FUNCTION getInput */
   49 
   50 void process()
   51 {
   52     /* FUNCTION process */
   53     if (m > n)
   54         printf ("%d\n", (m-1)+m*(n-1));
   55     else
   56         printf ("%d\n", (n-1)+n*(m-1));
   57 } /* FUNCTION process */
   58 
   59 int main()
   60 {
   61     /* main */
   62     int moreToDo;
   63 
   64     init();
   65     moreToDo = getInput();
   66     while (moreToDo)
   67         {
   68             /* while */
   69             process();
   70             moreToDo = getInput();
   71         } /* while */
   72 
   73     return EXIT_SUCCESS;
   74 } /* main */
   75