Compilation Error

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
Aengus
New poster
Posts: 12
Joined: Thu Oct 30, 2003 1:38 pm
Location: St. Petersburg, Russia
Contact:

Compilation Error

Post by Aengus » Fri Sep 16, 2005 11:02 am

I've got a compilation error with the following code. Could anybody help me?

Code: Select all

#include <stdio.h>
#include <math.h>

int
main()
{
  while (1)
  {
    int v;
    scanf("%d", &v);

    if (v == 0) break;

    int p = 1;
    int pp;
    for (pp = 2; pp < 32; pp++)
    {
      int r = exp(log(v)/pp);

      int rr = 1;
      int i;
      for (i = 0; i < pp; i++)
        rr *= r;

      if (rr == v) p = pp;

      r++;
      rr = 1;      
      for (i = 0; i < pp; i++)
        rr *= r;

      if (rr == v) p = pp;
    }

    printf("%d\n", p);
  }

  return 0;
}

misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post by misof » Fri Sep 16, 2005 11:45 am

Move all the variable declarations to the beginning of your code. Or, submit it as C++ code. (And to be on the safe side, replace log(v) by log(double(v)).)

Note that the UVa judge still uses gcc 2.95 with some weird switches.

Aengus
New poster
Posts: 12
Joined: Thu Oct 30, 2003 1:38 pm
Location: St. Petersburg, Russia
Contact:

Post by Aengus » Fri Sep 16, 2005 12:19 pm

Thanks for your advices!

Post Reply

Return to “C”