Computer Programming Contest Preparation

ToolBox - Source for: 101/10127/b.c



/home/toolbox/public_html/solutions/101/10127/b.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 /*
   16  *  Author:
   17  *    Date:
   18  * Purpose:
   19  * Problem:
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 int num;
   27 
   28 void init()
   29 {
   30     /* FUNCTION init */
   31 } /* FUNCTION init */
   32 
   33 void dump()
   34 {
   35     /* FUNCTION dump */
   36 } /* FUNCTION dump */
   37 
   38 int getInput()
   39 {
   40     /* FUNCTION getInput */
   41     int dataReadFlag;
   42 
   43     dataReadFlag = 1 == scanf("%d ", &num);
   44     return (dataReadFlag);
   45 } /* FUNCTION getInput */
   46 
   47 void process()
   48 {
   49     /* FUNCTION process */
   50     int cnt = 1;
   51     int ones = 1;
   52 
   53     while (0 < ones)
   54         {
   55             /* while */
   56             ones = ones * 10 + 1;
   57             cnt++;
   58             ones = ones % num;
   59         } /* while */
   60 
   61     printf("%d\n", cnt);
   62 } /* FUNCTION process */
   63 
   64 int main ()
   65 {
   66     /* main */
   67     int moreToDo;
   68 
   69     init();
   70     moreToDo = getInput();
   71     while (moreToDo)
   72         {
   73             /* while */
   74             process();
   75             moreToDo = getInput();
   76         } /* while */
   77 
   78     return EXIT_SUCCESS;
   79 } /* main */
   80