Computer Programming Contest Preparation

ToolBox - Source for: 2/294/c.c



/home/toolbox/public_html/solutions/2/294/c.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: Isaac Traxler
   19  *    Date: 20150922
   20  * Purpose: fun
   21  * Problem: 294 - divisors
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define MAX_NUMBER 1000000001
   29 
   30 int numberOfTimes;
   31 int L;
   32 int U;
   33 unsigned short ary[MAX_NUMBER];
   34 
   35 void init()
   36 {
   37     /* FUNCTION init */
   38     int i;
   39     int j;
   40     int tmp;
   41     int mx = 0;
   42 
   43     scanf("%d ", &numberOfTimes);
   44     ary[1] = 1;
   45     ary[2] = 2;
   46     ary[3] = 2;
   47     ary[4] = 3;
   48     ary[5] = 2;
   49     for (i=600000000; MAX_NUMBER>i; i++)
   50         {
   51             /* try each number */
   52             ary[i] = 2;
   53             tmp=sqrt(i);
   54             if ((tmp * tmp) == i)
   55                 {
   56                     ary[i] = 1;
   57                 }
   58             printf("i=%d  tm[=%d\n", i, tmp);
   59             for (j=2; j<tmp; j++)
   60                 {
   61                     /* for each possible divisor */
   62                     if (0 == (i % j))
   63                         {
   64                             ary[i] = ary[i] + 2;
   65                         }
   66                 } /* for each possible divisor */
   67             DEBUG printf("%d: %d\n", i, ary[i]);
   68             if (mx < ary[i])
   69                 {
   70                     mx = ary[i];
   71                 }
   72         } /* try each number */
   73     printf("max = %d\n", mx);
   74 } /* FUNCTION init */
   75 
   76 void dump()
   77 {
   78     /* FUNCTION dump */
   79 } /* FUNCTION dump */
   80 
   81 void getInput()
   82 {
   83     /* FUNCTION getInput */
   84     scanf(" %d %d ", &L, &U);
   85 } /* FUNCTION getInput */
   86 
   87 void process()
   88 {
   89     /* FUNCTION process */
   90 } /* FUNCTION process */
   91 
   92 int main()
   93 {
   94     /* main */
   95     int i;
   96 
   97     init();
   98     for (i=0; i<numberOfTimes; i++)
   99         {
  100             /* while */
  101             getInput();
  102             process();
  103         } /* while */
  104 
  105     return EXIT_SUCCESS;
  106 } /* main */
  107 
  108