## 10484 - Divisibility of Factors

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
you don't consider the case that cnt<0, for example input 2 8.

Tomson
New poster
Posts: 12
Joined: Wed Mar 19, 2003 2:03 pm
Oh, Yes , I neglected this point, Now I got AC
Thank you very much

Jalal
Learning poster
Posts: 65
Joined: Sun Jun 02, 2002 8:41 pm
Contact:
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 };

Dmytro Chernysh
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?

Pier
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
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);
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);
end;
End.
[/pascal]
There are 10 kind of people on this world: those who understand binary and those who don't!

Noim
Learning poster
Posts: 88
Joined: Sun Oct 13, 2002 6:11 am
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:
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);
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....

soyoja
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.

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 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.

soyoja
Experienced poster
Posts: 106
Joined: Sun Feb 17, 2002 2:00 am
Location: Seoul, South Korea
Contact:
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?

Noim
Learning poster
Posts: 88
Joined: Sun Oct 13, 2002 6:11 am
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.
__nOi.m....

Daredevil
New poster
Posts: 19
Joined: Tue Apr 01, 2003 7:47 am
Location: Earth

### 10484 - Never mind it

Could anybody help me??
I got WA all the time.

Here's my code:
[c]
????????????????
[/c]

Never mind!!

yahoo
Learning poster
Posts: 93
Joined: Tue Apr 23, 2002 9:55 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.

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.

samueljj
New poster
Posts: 18
Joined: Fri Jul 18, 2003 5:24 am

### 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 :

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;}

}``````
novice programmer

samueljj
New poster
Posts: 18
Joined: Fri Jul 18, 2003 5:24 am

### 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...
novice programmer

jamu
New poster
Posts: 13
Joined: Wed Dec 03, 2003 11:15 am
Hi, these are my sample input/output:

input:
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
my output:
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
is my output ok?