Page 3 of 8
WA. works for all kinds of test inputs
Posted: Sat Mar 29, 2003 2:20 pm
by Derk
I can't find my error here.. I've tried all inputs I could think of...
Here's my code and the test I/O I'm using...
[c] int m,n;
while(scanf("%d %d", &n, &m)==2)
{
if (m>n || m == 0 || n == 0)
printf("Boring!\n");
else if (m==n && m != 1)
printf("%d 1\n", m);
else if (m==n && m == 1)
printf("Boring!\n");
else
if(!((float)(log(n)/log(m)) == (float)(int)(log(n)/log(m))) )
printf("Boring!\n");
else
{
while(n!=1)
{
printf("%d ", n);
n=n/m;
}
printf("1\n");
}
}[/c]
And my input:
Code: Select all
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 88
88 1
1 1
And the output:
Code: Select all
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!
10190 - Pls help
Posted: Thu Sep 11, 2003 12:38 pm
by Master
hi,
this is my code:
[cpp]
#include<iostream.h>
#define MAX 100
main(void)
{
unsigned long long a[MAX],m;
int i,t;
while(cin >> a[0] >> m)
{
i=0;
t=1;
while(a
!=1)
{
if(a % m)
{
t = 0;
break;
}
i++;
m = (unsigned long long)(a[i-1]/m);
a = m;
if(!(a[i-1]>a))
{
t = 0;
break;
}
}
if(t)
for(m=0;m<=i;m++)
cout << a[m] << " ";
else
cout << "Boring!";
cout << endl;
}
return 0;
}[/cpp]
this is getting Runtime error
Your program has died with signal 8 (SIGFPE). Meaning:
Floating point exception
Before crash, it ran during 0.000 seconds.
Pls tell me what is the error.
M H Rasel
CUET Old Sailor
Posted: Fri Sep 12, 2003 6:06 am
by Joseph Kurniawan
SIGFPE most oftenly occurs when there's a division by zero performed during the program execution.
The input will consist on an arbitrary number of lines. Each line will consist of two non-negative integers n,m which are both less than 2000000000. You must read until you reach the end of file.
You program can't handle the input where m is zero (since zero is also non negative integer). In the case where m is zero, there will be a division by zero and thus produce SIGFPE!!
Hope it helps!!
Posted: Sun Sep 14, 2003 4:31 am
by Master
Thanks a lot.
I will try with this way.
M H Rasel
CUET Old Sailor
Posted: Sun Sep 14, 2003 4:42 am
by Dmytro Chernysh
I can give you input/output...
Mail me.
10190 WA :(
Posted: Wed Feb 04, 2004 8:00 am
by aakash_mandhar
I have tested he code for all inputs i could think of. I would be great if any of u guys could tell me what is wrong with the code or just tell me the test case where it fails...
I use log to check if it is a power or not and then start dividing......
[cpp]
# include<iostream.h>
# include<math.h>
long long a,n;
double x;
int main()
{
while(cin>>a>>n)
{
if(a<=1 || n<=1) {cout<<"Boring!\n";continue;}
x=log(a)/log(n);
if(fabs(x-int(x))<=1e-7)
{
do
{
cout<<a<<" ";
a/=n;
}
while(a!=1);
cout<<1<<"\n";
}
else
{
cout<<"Boring!\n";
}
}
return 1;
}
[/cpp]
Posted: Sat Feb 07, 2004 8:03 am
by Master
Get AC.
Thanks all of you.
M H Rasel
CUET Old Sailor.
Posted: Mon May 10, 2004 9:24 am
by Amir Aavani
may be your problem is in log function ( i mean that floating point error). why you don't devide a by n in your while and check if new a is a devisor of n.
something like this:
i:= 0;
while (a mod n= 0) do
begin
Inc (i);
No := a div n;
a:= a div n;
end;
if a= 1 then
for i:= 1 to i do
Write (No )
else
Write ('boaring');
Posted: Fri May 21, 2004 11:17 am
by Examiner
Why is the answer "Boring!" but not "1", when n = 1 and 0 ≤ m < 2,000,000,000? Can't k be 1?
Posted: Fri May 21, 2004 2:22 pm
by UFP2161
It says in the restrictions that k > 1.
Posted: Fri May 21, 2004 8:25 pm
by Examiner
Do you refer to this line?
a[1] = n, a = a[i-1] div m, for all 1 < i <= k
Now I understand what you mean. I interpreted the inequality "1 < i ≤ k" as only a restriction on i. When k ≤ 1, this inequlity never holds, so the quoted statement is always satisfied. But you think the statement is also a restriction on k.
Thank you for your reply.
10190 Runtime Error:(acc)
Posted: Tue Jun 15, 2004 7:37 am
by kami
what is the problem in this code any one help me
giving me runtime error
code
Posted: Tue Oct 12, 2004 5:47 am
by yiuyuho
a[1] = n, a = a[i-1] div m, for all 1 < i <= k
why/how would that imply k>1?
that statement is the same as
a[1]=n, a=a[i-1] div m, for all 1<i AND i<=k
so when k is 1, you got
a[1]=n, a=a[i-1] div m, for all 1<i AND i<=1,
all it means is there is not such integer i.
and the statement is true.
Say we have
For all x in S, f(x).
if S is Empty Set, then statement is true, right?
Posted: Wed Jan 26, 2005 7:36 am
by gits
yiuyuho, I totally agree with you. However, in my first submission I produced output "1" for input "1 1" and got WA, then changed it to "Boring!" and it was accepted.
So k must be > 1, but the description isn't very accurate.
10190-need I/O For Test
Posted: Mon Mar 21, 2005 6:59 am
by Rocky
Hi All Solver
I need Some Data For 10190
I test it with all possible condition BUT i get WA all Time
Can any body help me
ROCKY
THANK's IN ADVANCE