11549 - Calculator Conundrum
Moderator: Board moderators
11549 - Calculator Conundrum
Give me hints please..!!
Re: 11549 - CALCULATOR CONUNDRUM
use cycle detection algorithm like http://en.wikipedia.org/wiki/Floyd_cycl ... _algorithm
Re: 11549 - CALCULATOR CONUNDRUM
I am getting TLE using Cycle detection algorithm...
Code: Select all
got AC
Last edited by Ron on Wed Nov 12, 2008 3:55 pm, edited 1 time in total.
-
- A great helper
- Posts: 281
- Joined: Tue Sep 10, 2002 5:14 am
- Location: Mountain View, CA, USA
- Contact:
Re: 11549 - CALCULATOR CONUNDRUM
Or you could just remember all of the numbers you've seen so far and stop as soon as you reach a previously seen number. That's what I did.pvncad wrote:use cycle detection algorithm
If only I had as much free time as I did in college...
Re: 11549 - CALCULATOR CONUNDRUM
How did you store previous numbers after find new number by given function ??Abednego wrote :
Or you could just remember all of the numbers you've seen so far and stop as soon as you reach a previously seen number. That's what I did.
Last edited by Ron on Wed Nov 12, 2008 6:20 am, edited 1 time in total.
-
- A great helper
- Posts: 281
- Joined: Tue Sep 10, 2002 5:14 am
- Location: Mountain View, CA, USA
- Contact:
Re: 11549 - CALCULATOR CONUNDRUM
Code: Select all
set<int> seen;
If only I had as much free time as I did in college...
Re: 11549 - CALCULATOR CONUNDRUM
Still, i am getting TLE 
The problem was in my function in which i was taking so much time to find next number.

Code: Select all
finally .. AC
-
- Learning poster
- Posts: 76
- Joined: Mon Jul 21, 2008 8:50 am
- Location: SUST,SYLHET,BANGLADESH.
- Contact:
Re: 11549 - CALCULATOR CONUNDRUM
i have got AC in this prob. but it took huge time 4.150 sec.
can any one pls explain the floyd's cycle finding algo pls
?? i have read abt it in wiki but couldnt understand
.
can any one pls explain the floyd's cycle finding algo pls





Heal The World
-
- Learning poster
- Posts: 74
- Joined: Fri May 08, 2009 5:16 pm
Re: 11549 - CALCULATOR CONUNDRUM
u can use map,to find the no that was found before,
u can declare map lyk this,
#include<map>
......
map<int,int>map_name;
.....
u can declare map lyk this,
#include<map>
......
map<int,int>map_name;
.....
11549 - CALCULATOR CONUNDRUM
could someone give me some IO to test?
I got WA...
I got WA...
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET