Could anyone tell me some special IO for this problem ?
I got WA, and I can send my code if anyone want to help me ...
Best regards
Dominik Michniewski
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
I handle negative values for D because I heve line:
if(D < 0) D = -D;
maybe its incorrect ? I think that's no matter with sign of D
turuthok,, I send you my code .... thanks for help
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
I've got it. Thanks all for help, especially thanks for turuthok )
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
void main()
{
int n , d;
cin >> n >> d;
while ( n || d ) {
if ( n==0)
cout << 0 << endl;
else {
if ( d<0 )
d = -d;
memset(cnt , 0 , sizeof(cnt));
int i = 0;
while ( primes <= n ) {
int t = primes;
while ( t <= n ) {
cnt += n/t;
t *= primes;
}
i ++;
}
i = 0;
while ( primes <= n ) {
while ( d%primes==0 ) {
cnt --;
d /= primes;
}
i ++;
}
if ( d>1 )
cout << 0 << endl;
else {
long long r = 1;
i = 0;
while ( primes <= n ) {
if ( cnt )
r *= (long long)(cnt[i] + 1);
i ++;
}
cout << r << endl;
}
}
cin >> n >> d;
}
}
[/cpp]
your mean is because 0! equals 1, if n==0, 1 should be outputed but 0,
didn't it?
I modified this bug, but I still got WA.
Why????
[cpp]
#include <iostream.h>
#include <memory.h>
void main()
{
int n , d;
cin >> n >> d;
while ( n || d ) {
if ( n==0)
cout << 1 << endl;
else {
if ( d<0 )
d = -d;
memset(cnt , 0 , sizeof(cnt));
int i = 0;
while ( primes <= n ) {
int t = primes;
while ( t <= n ) {
cnt += n/t;
t *= primes;
}
i ++;
}
i = 0;
while ( primes <= n ) {
while ( d%primes==0 ) {
cnt --;
d /= primes;
}
i ++;
}
if ( d>1 )
cout << 0 << endl;
else {
long long r = 1;
i = 0;
while ( primes <= n ) {
if ( cnt )
r *= (long long)(cnt[i] + 1);
i ++;
}
cout << r << endl;
}
}
cin >> n >> d;
}
}
[/cpp]
I've changed my code as
[cpp]
if ( n==0 ) {
if ( d==1 )
cout << 1 << endl;
else
cout << 0 << endl;
}
[/cpp]
but I still got WA.
I don't know why, can you help me?
Oh, My luck is so bad. Yes, I've considered the case that d = -1, but still got WA.
here is my code. I' m so puzzle. can you give me some help?
[cpp]
#include <iostream.h>
#include <memory.h>
void main()
{
int n , d;
cin >> n >> d;
while ( n || d ) {
if ( d<0 )
d = -d;
if ( n==0 ) {
if ( d==1 )
cout << 1 << endl;
else
cout << 0 << endl;
}
else {
memset(cnt , 0 , sizeof(cnt));
int i = 0;
while ( primes <= n ) {
int t = primes;
while ( t <= n ) {
cnt += n/t;
t *= primes;
}
i ++;
}
i = 0;
while ( primes <= n ) {
while ( d%primes==0 ) {
cnt --;
d /= primes;
}
i ++;
}
if ( d>1 )
cout << 0 << endl;
else {
long long r;
i = 0;
while ( primes <= n ) {
if ( cnt )
r *= (long long)(cnt[i] + 1);
i ++;
}
cout << r << endl;
}
}
cin >> n >> d;
}
}
[/cpp]