Page 2 of 8

Posted: Tue Jan 28, 2003 6:50 pm
by haoto
Nope...
I think the judge is right, because k must >1. :-?

10190: TLE.. help, plz

Posted: Sun Mar 09, 2003 12:40 am
by Sajid
i have got Time Limit Exceeded in this problem. what is the effiecient algorithm for this problem? help,. plz

Posted: Sun Mar 09, 2003 5:12 am
by Whinii F.
I think simple division algorithm is enough to handle this problem, since the algorithm's time complexity is O(log_m_n) .. So the longest run will not be longer than 31. =)

I think you don't handle some EXCEPTIONAL cases correctly..

Posted: Sun Mar 09, 2003 6:18 am
by Sajid
Since September 28th 2002 the default CPU limit is 10 seconds.

......

anyway, what's the eXceptional cases?

Posted: Sun Mar 09, 2003 8:20 am
by Whinii F.
Why don't you try to figure it out on your own?
Knowing solutions before thinking deeply doesn't have any effects. It's use for nothing.

anyway, I'll give one more hint:
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.
It's non-negative. right?

Posted: Sun Mar 09, 2003 9:59 am
by Sajid
sorry, it's my fault. there was some problem with the input 0 and 1.

any way, plz check it...

Input:

Code: Select all

0 0
0 1
1 0
1 88
88 1
Output:

Code: Select all

Boring!
Boring!
Boring!
Boring!
88
is it ok???

Posted: Sun Mar 09, 2003 10:00 am
by Sajid
sorry, it's my fault. there was some problem with the input 0 and 1.

any way, plz check it...

Input:

Code: Select all

0 0
0 1
1 0
1 88
88 1
Output:

Code: Select all

Boring!
Boring!
Boring!
Boring!
88
is it ok???

Posted: Sun Mar 09, 2003 11:21 am
by Whinii F.
The first four are okay, the last one is not..
It doesn't end with 1, so it must be a "boring!" sequence.

Good luck =)

Posted: Sun Mar 09, 2003 2:09 pm
by Sajid
sorry, still WA...

Input:

Code: Select all

1 1
Output:

Code: Select all

1
is it correct?

Posted: Sun Mar 09, 2003 10:47 pm
by Jalal
No sajid its output is
Boring!
:wink:

thanX

Posted: Sun Mar 09, 2003 11:06 pm
by Sajid
Jalal Bhaiya, thanx for ur help...

and Whinii as well.


Jalal Bhai, dowa rakhben. :wink:

Posted: Sat Mar 15, 2003 7:40 pm
by yahoo
I can't understand why i got wrong answer all the time in this problem. I have tested my program with all known typical test cases. Can anybody tell where my code is wrong. Thanks in advance. Here is my code:

Code: Select all

code has been remove because after some modification it got accepted.

Posted: Sun Mar 16, 2003 12:38 am
by bery olivier
yahoo wrote: [c]
while(1)
{
r=scanf("%lld%lld",&n,&m);
if(r==EOF) break;
[/c]
Humm, :-? This seems incorrect to me.

You can use
[c]
while(1)
{
r=scanf("%lld%lld",&n,&m);
if(m==EOF || n==EOF) break;
[/c]

or better :
[c]
while(1)
{
r=scanf("%lld%lld",&n,&m);
if(r!=2) break;
[/c]

But I don't really like this. Better use this, it's shorter and more safe. Moreover, you don't need to use 'r' nor a 'break'.
[c]
while(scanf("%lld%lld",&n,&m)==2)
[/c]

Hope it'll help

Posted: Sun Mar 16, 2003 11:05 am
by bery olivier
you must do k-1 succesive divisions to reach n = 1
You should print the results only if (n%m)!=0 until the end.
try these inputs

Code: Select all

999 111
55 11
40 20
8 4
it gives me

Code: Select all

999 9
55 5
40 2
8 2
But this gives me better outputs
[c] if(!flag || a[i-1]!=1) printf("Boring!\n"); [/c]

I just tested it and I got accepted. :P . Enjoy :wink:

Posted: Sun Mar 16, 2003 4:27 pm
by yahoo
Thank you very very much for you kind reply. I have got accepted. :P :D