Posted:

**Thu May 01, 2003 1:27 pm**you don't consider the case that cnt

*<0, for example input 2 8.*The UVa Online Judge board

https://uva.onlinejudge.org/board/

Page **2** of **3**

Posted: **Thu May 01, 2003 1:27 pm**

you don't consider the case that cnt*<0, for example input 2 8.*

Posted: **Thu May 01, 2003 3:06 pm**

Oh, Yes , I neglected this point, Now I got AC

Thank you very much

Thank you very much

Posted: **Fri May 16, 2003 2:00 am**

Your algorithm is not clear...........

As far i know according to the way u make a array of primes

must 101 after 97......

but u made 101 cheak it

int primes[26] = {

2,

3,

5,

7,

11,

13,

17,

19,

23,

29,

31,

37,

41,

43,

47,

53,

59,

61,

67,

71,

73,

79,

83,

89,

97,

111 };

As far i know according to the way u make a array of primes

must 101 after 97......

but u made 101 cheak it

int primes[26] = {

2,

3,

5,

7,

11,

13,

17,

19,

23,

29,

31,

37,

41,

43,

47,

53,

59,

61,

67,

71,

73,

79,

83,

89,

97,

111 };

Posted: **Fri May 16, 2003 3:42 am**

I guess, you don't have all prime numbers - what about number 101?

Posted: **Tue Jun 10, 2003 6:41 pm**

I keep getting WA. Any help appreciated!

[pascal]{Wrong Answer 0:00.100 64}

{$N+}

Const

p: array [1..25] of byte=

(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97);

Var

i: byte;

n,d,t: longint;

r: extended;

pn: array [1..25] of byte;

Begin

readln(input,n,d);

While (n<>0) or (d<>0) do

begin

if d<0 then d:= -d;

if (n<d) and (d<>1) then

begin

writeln(output,0);

readln(input,n,d);

continue;

end;

fillchar(pn,sizeof(pn),1); r:= 1;

for i:= 1 to 25 do

begin

t:= p*;*

While (t<100) do

begin

Inc(pn*,n div t);*

t:= t*p*;*

end;

end;

for i:= 1 to 25 do

While (d mod p*= 0) do*

begin

d:= d div p*;*

Dec(pn*);*

end;

for i:= 1 to 25 do

r:= r*pn*;*

if d= 1 then writeln(output,r:0:0)

else writeln(output,0);

readln(input,n,d);

end;

End.

[/pascal]

[pascal]{Wrong Answer 0:00.100 64}

{$N+}

Const

p: array [1..25] of byte=

(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97);

Var

i: byte;

n,d,t: longint;

r: extended;

pn: array [1..25] of byte;

Begin

readln(input,n,d);

While (n<>0) or (d<>0) do

begin

if d<0 then d:= -d;

if (n<d) and (d<>1) then

begin

writeln(output,0);

readln(input,n,d);

continue;

end;

fillchar(pn,sizeof(pn),1); r:= 1;

for i:= 1 to 25 do

begin

t:= p

While (t<100) do

begin

Inc(pn

t:= t*p

end;

end;

for i:= 1 to 25 do

While (d mod p

begin

d:= d div p

Dec(pn

end;

for i:= 1 to 25 do

r:= r*pn

if d= 1 then writeln(output,r:0:0)

else writeln(output,0);

readln(input,n,d);

end;

End.

[/pascal]

Posted: **Tue Jun 10, 2003 9:04 pm**

hi peir,

i am not a pascal programmer. but what i can understand to see your code,

do you consider adrian Kusel's input which is written top of this page:

and again what in your code is :

what should be the answer for the input: 10 12

does your code show the right output ??? output will be -> 168.

hi jalal,

for this program , i don't think prime 101 is essential.

so that will not make any harm for this program.

as the maximum input of n for this program is 100.

i am not a pascal programmer. but what i can understand to see your code,

do you consider adrian Kusel's input which is written top of this page:

you don't consider the case that cnt<0, for example input 2 8.

and again what in your code is :

if (n<d) and (d<>1) then

begin

writeln(output,0);

readln(input,n,d);

continue;

end;

what should be the answer for the input: 10 12

does your code show the right output ??? output will be -> 168.

hi jalal,

for this program , i don't think prime 101 is essential.

so that will not make any harm for this program.

as the maximum input of n for this program is 100.

Posted: **Mon Jul 14, 2003 6:05 am**

I got WA many times....

Are there some critical input data?

If you know, please tell me about them.

P.S) If it help to adviser, I'll post my WA source code here.

Are there some critical input data?

If you know, please tell me about them.

P.S) If it help to adviser, I'll post my WA source code here.

Posted: **Mon Jul 14, 2003 7:21 am**

Becarefull D can be negative value, and don't forget use long long.

As I know there are no tricky input here.

If you still can't get AC, send me your code I'll try to help.

As I know there are no tricky input here.

If you still can't get AC, send me your code I'll try to help.

Posted: **Tue Jul 15, 2003 3:44 pm**

First, I used long long data type...

Anyway, Thanks for youe reply. But I have a question.

If D is negative number, then I write

if( D < 0 ) D *= -1;

Is it right?

Please tell me...

Anyway, Thanks for youe reply. But I have a question.

If D is negative number, then I write

if( D < 0 ) D *= -1;

Is it right?

Please tell me...

Posted: **Tue Jul 15, 2003 4:32 pm**

soyoja vai,

your code (mentioned in your last submission ) seems right to me.

you can try for the input below

input:

2 16

output:

0

i have got 1 WA for this input first time.

your code (mentioned in your last submission ) seems right to me.

you can try for the input below

input:

2 16

output:

0

i have got 1 WA for this input first time.

Posted: **Wed Sep 17, 2003 7:12 am**

Could anybody help me??

I got WA all the time.

Here's my code:

[c]

????????????????

[/c]

Never mind!!

I got WA all the time.

Here's my code:

[c]

????????????????

[/c]

Never mind!!

Posted: **Tue Oct 14, 2003 8:49 am**

Red Scorpion wrote:Becarefull D can be negative value, and don't forget use long long.

As I know there are no tricky input here.

If you still can't get AC, send me your code I'll try to help.

Posted: **Tue Jun 15, 2004 7:35 pm**

hi... can any state why i am getting runtime error watching the following code...i dont have some condition which can result to WA... but can't get why this error is occuring...

my code :

my code :

Code: Select all

```
#include<stdio.h>
#include<math.h>
void divisible_generator();
void input_divisible(long long int);
long long int b[101],a[121][101],counter;
void main()
{
long long int i,j,k,n,m,c;
divisible_generator();
for(;;)
{
scanf("%lld %lld",&n,&m);
break;
if(n==0&&m==0) break;
else
{
input_divisible(m);k=c=1;
for(i=0;i<counter;i++)
{
if(a[n][b[i]]>0)
{
if(a[120][b[i]]>0)
if(a[120][b[i]]>a[n][b[i]]) {c=0;break;}
else j=a[n][b[i]]-a[200][b[i]];
else j=a[n][b[i]]+1;
k*=j;
}
else if(a[120][b[i]]>0&&a[n][b[i]]==0) {c=0;break;}
}
if(c==0) printf("0\n");
else printf("%lld\n",k);
}
}
}
void divisible_generator()
{
long long int i,j,k,n;
for(i=1;i<=100;i++)
{n=i;
for(j=1;j<=100;j++)
a[i][j]=a[i-1][j];
for(;n>1;)
for(k=2;k<=n;k++)
if(n%k==0)
{a[i][k]++;n/=k;break;}
}
for(j=1,counter=0;j<=100;j++)
if(a[i-1][j]>0)
{b[counter]=j;
counter++;
}
}
void input_divisible(long long int n)
{
long long int i,j,k;
for(j=1;j<=100;j++)
a[120][j]=0;
for(;n>1;)
for(k=2;k<=n;k++)
if(n%k==0)
{a[120][k]++;n/=k;break;}
}
```

Posted: **Tue Jun 15, 2004 7:51 pm**

i pointed out... the -ve may lead to runtime error as invalid memory location.. so changed..

if(m<0) m=-m;

still cant solve the runtime error can any 1 help...

if(m<0) m=-m;

still cant solve the runtime error can any 1 help...

Posted: **Thu Jul 08, 2004 11:33 am**

Hi, these are my sample input/output:

input:

thanks in advance

input:

my output:0 -10

0 -5

0 -1

0 1

0 5

0 10

1 0

1 -1

1 1

1 -2

1 2

2 -4

2 -3

2 -2

2 -1

2 0

2 1

2 2

2 3

2 4

3 -8

3 -7

3 -6

3 -5

3 -4

3 -3

3 -2

3 -1

3 0

3 1

3 2

3 3

3 4

3 5

3 6

3 7

3 8

12 -18

13 15

18 29

25 -25

80 17

80 1

80 2

100 2

100 3

100 11

100 -1

100 1

0 0

is my output ok?0

0

1

1

0

0

0

1

1

0

0

0

0

1

1

0

1

1

0

0

0

0

1

0

0

2

2

3

0

3

2

2

0

0

1

0

0

480

880

0

242880

94133433139200

117666791423999

116177338368000

38603278909440000

38205306961920000

35101125771264000

39001250856959999

39001250856959999

thanks in advance