11549 - Calculator Conundrum

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

Moderator: Board moderators

Post Reply
Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

11549 - Calculator Conundrum

Post by Ron »

Give me hints please..!!
pvncad
New poster
Posts: 27
Joined: Sun Feb 18, 2007 2:14 pm

Re: 11549 - CALCULATOR CONUNDRUM

Post by pvncad »

Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

Re: 11549 - CALCULATOR CONUNDRUM

Post by Ron »

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.
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

Re: 11549 - CALCULATOR CONUNDRUM

Post by Abednego »

pvncad wrote:use cycle detection algorithm
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.
If only I had as much free time as I did in college...
Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

Re: 11549 - CALCULATOR CONUNDRUM

Post by Ron »

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.
How did you store previous numbers after find new number by given function ??
Last edited by Ron on Wed Nov 12, 2008 6:20 am, edited 1 time in total.
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

Re: 11549 - CALCULATOR CONUNDRUM

Post by Abednego »

Code: Select all

set<int> seen;
You could also set up a huge bit vector to make updates O(1), as long as you only use one bit per number, but it wasn't necessary.
If only I had as much free time as I did in college...
Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

Re: 11549 - CALCULATOR CONUNDRUM

Post by Ron »

Still, i am getting TLE :(

Code: Select all

finally .. AC
The problem was in my function in which i was taking so much time to find next number.
calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am
Location: SUST,SYLHET,BANGLADESH.
Contact:

Re: 11549 - CALCULATOR CONUNDRUM

Post by calicratis19 »

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 8) 8) ?? i have read abt it in wiki but couldnt understand :cry: :cry: :cry: .
Heal The World
Jehad Uddin
Learning poster
Posts: 74
Joined: Fri May 08, 2009 5:16 pm

Re: 11549 - CALCULATOR CONUNDRUM

Post by Jehad Uddin »

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;
.....
lionking
New poster
Posts: 9
Joined: Tue Feb 17, 2009 6:46 pm

11549 - CALCULATOR CONUNDRUM

Post by lionking »

could someone give me some IO to test?

I got WA...
saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11549 - CALCULATOR CONUNDRUM

Post by saiful_sust »

Hi try this case:
input:

Code: Select all

3
45 3
3 45
5 12
output:

Code: Select all

9
992
99162
Post Reply

Return to “Volume 115 (11500-11599)”