10484  Divisibility of Factors
Moderator: Board moderators

 Guru
 Posts: 724
 Joined: Wed Dec 19, 2001 2:00 am
 Location: Germany

 Experienced poster
 Posts: 146
 Joined: Sat Apr 26, 2003 2:51 am
Well
I guess, you don't have all prime numbers  what about number 101?

 New poster
 Posts: 38
 Joined: Thu Mar 27, 2003 9:12 pm
 Location: Aguascalientes, Mexico
 Contact:
Why WA!
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,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]
There are 10 kind of people on this world: those who understand binary and those who don't!
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.
__nOi.m....

 Experienced poster
 Posts: 106
 Joined: Sun Feb 17, 2002 2:00 am
 Location: Seoul, South Korea
 Contact:
10484 Divisibility of Factors
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.

 Experienced poster
 Posts: 192
 Joined: Sat Nov 30, 2002 5:14 am
10484  Never mind it
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!!
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.
i am sure that there is no input with d<0 because i when i ran my code it gave different ans for d<0 and d>0 but got ac by judge.
10484 runtime error...can any one help
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[i1][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[i1][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;}
}
novice programmer
still getting...runtime...
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...
novice programmer
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