Page 4 of 8

Posted: Fri Apr 29, 2005 1:07 pm
by Sedefcho
Rocky,

You can try the input I post below and check if your program
produces the same output as mine ( my program is
an ACC program ).

By the way, you may also check this thread
http://online-judge.uva.es/board/viewtopic.php?t=2474


INPUT

Code: Select all

127  0  
12 7 
127 1
1 1 
22 0
0 0
   0 1 
0 9
125 5 
30    3 
80  2 
81 3 
    64 4 
64 2 
64 1 
60 1 
60 2 
60 3 
60 4 
60 5
       1000000000 500 
1999999999 9 
387420489 9 
387420489 8 
387420489 10 
312500000 50 
312500000 51 
312500000 49 
0 0 
0 1 
1 0 
1 1
22 1
15 1
1 88 
88 1 
1 1
12 1
1 12
100 100
100 50
256 16
256 4
333333 333
4096 16
1024 16

OUTPUT

Code: Select all

Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
125 25 5 1
Boring!
Boring!
81 27 9 3 1
64 16 4 1
64 32 16 8 4 2 1
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
387420489 43046721 4782969 531441 59049 6561 729 81 9 1
Boring!
Boring!
312500000 6250000 125000 2500 50 1
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
100 1
Boring!
256 16 1
256 64 16 4 1
Boring!
4096 256 16 1
Boring!
I hope this helps.

Posted: Fri Apr 29, 2005 1:12 pm
by Sedefcho
Just to confirm.

The output of DERK ( Posted: Sat Mar 29, 2003 2:20 pm ) is correct.
My ACC program gives same
output when I use the input he/she has posted.

The remark from GITS is correct.
If N is equal to 1 we should directly print "Boring!" no matter
what the value of M is.
That's not very clear from the problem statement, I agree.

Acc 10190

Posted: Mon May 02, 2005 6:05 am
by Rocky
Thank's Sedefcho For Your Reply.
I GOt Acc Now.

10190 , please help me i am getting run time error

Posted: Thu Jun 09, 2005 2:03 am
by thinker_bd
i got accepted

Posted: Thu Jun 09, 2005 5:57 am
by sumankar
Change the array limit to something bigger and check, its usually array indices out of bound that would give you a RTE/SEGfault.
And dont use`//' for comments if you are to submit it as a C program.

10190 Still run time error

Posted: Thu Jun 09, 2005 10:27 pm
by thinker_bd
my program is accepted so i remove my code

Posted: Thu Jun 09, 2005 10:37 pm
by jaracz
You should check if m != 0!!!!!!!!

Remember that we cannot devide through 0!
That's why you're gettin' RTE
You don't have to enlarge your array instead

Have a nice WA:)
Regards

10190 after checking m=0 and array but till RTE

Posted: Fri Jun 10, 2005 8:19 pm
by thinker_bd
code removed

Thinker BD !!

Posted: Fri Jun 10, 2005 10:55 pm
by Raj Ariyan
Hi Thinker Bangladesh,
You wrote --
while(1)
{
if(flag==1)
break;

if((n%m)!=0)
{
flag=1;
break;
}
array=n/m;
n=n/m;
if(n==1)
break;
i++;
}


I think this is not ok, sometime it may gets overflow or (n%0). Though if u correct it then u will get P.E, rite ? Why u make it so complex, if n is not proper power m then boring, else just print

Code: Select all

printf("%d",n);
while(n!=1)
     printf(" %d",(n/=m));
printf("\n");
Isnt it so easy ??? Always think in a Simple way !!!

Posted: Sat Jun 11, 2005 2:34 am
by thinker_bd
mr RAJ i dont understand what u mean by

"if n is not proper power m then boring........"
............
...........

what is proper power how i check it
please can say me clearly how i implement this line

10190

Posted: Sat Jun 11, 2005 6:59 am
by Raj Ariyan
Hi Thinker,
Let see the first input. In our first input there is n=125,m=5. In this input n is a proper power of 5, i means 5^3=125, right ? if so then just implement what i say in my last thread. If no, say abt our second input, n=30,m=3, there is no power which makes m^x=n, so the output should be "boring". Same things also happens with third input. And the last input, n=81,m=3, then 3^4=81, so u have to print 3^4 , 3^3, 3^2, 3^1, 3^0. Understand ? Good Luck.

but TLE

Posted: Sat Jun 11, 2005 7:25 pm
by thinker_bd
my code removed

Hi Thinker

Posted: Sun Jun 12, 2005 6:44 am
by Raj Ariyan
Hi,
Try to understand. The max limit is 2000000000, so when compare the value with power sometime it may exceeds int limit. So use unsingned int. In ur while condition u take input as %lu, then u print the value with
%d !!!!! Another things make a check in ur while loop
if(m<2 || n<2)
break;

So make it:-

Code: Select all

while(1) 
		{ 
			if(n<2 || m<2)
				break;

			tmp=(int)pow(m,i); 
			if(tmp>n) 
				break; 
			if(tmp==n) 
			{ 
				flag=1; 
				break; 
			} 
			i++; 
		} 
Hope it helps.

THANX MR RAJ

Posted: Sun Jun 12, 2005 7:31 pm
by thinker_bd
THANX MR RAJ , AT LAST I GOT ACCEPTED IN 10190 AFTER 25!! SUBMISSION.

10190-pls pls help!

Posted: Fri Aug 12, 2005 9:47 pm
by 59557RC
i made more than 20 submissions 4 this pob. i dont find the mistake why it gets WA.any1 pls help me:

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

int main()
{
long n,m,i,j,kk,kkk,p;
double k,l;

while(scanf("%ld %ld",&n,&m)!=EOF){p=1;
if(n==1) {printf("Boring\n");continue;}
else if(m==0 || n==0) {printf("Boring!\n");continue;}


if(n>1 && m==1){
kkk=sqrt(n);
for(i=2;i<=kkk;i++){
for(j=2;j<=31;j++){
if(pow(i,j)==n){ p=0;break;}
else if(pow(i,j)>n) break;

}
if(p==0) break;
}
if(p==0){
for(;j>=0;j--){kk=pow(i,j); printf("%ld ",kk);}
printf("\n");
}
else printf("Boring!\n");
continue;







}





for(i=1;;i++) {
k=pow(m,i);
if(k==n) {
for(j=i;j>=0;j--) {kk=pow(m,j);printf("%ld ",kk);}
printf("\n");break;
}
else if(k>n) {printf("Boring!\n");break;}
}

}
return 0;
}