C Board  

Go Back   C Board > Community Boards > Contests Board

Reply
 
LinkBack Thread Tools Display Modes
Old 12-03-2005, 05:30 AM   #1
Registered User
 
Join Date: May 2005
Posts: 76
Problem - 2 elevators, when do they meet ?

Hi, I have such problem: there is 2 elevators in a one building of x floors, they drive only upwards. And we have such data (for example):
1. elevator:
a1=1
r=3
2. elevator
a1=2
r=4

a1 is a numer of the floor from which each elevator starts and r is a period of an elevator breaks - for example, second elevator starts on the 2nd floor, then it stops on the 6h, 10th, 14th and so on and so forth. And here is my question, how to calculate the lowest number of the floor on which two elevators meets and what the period would be? I know that they will meet when GCD(r_1,r_2)|p where p is |a1_1 - a1_2|.
Regards,
apacz
apacz is offline   Reply With Quote
Old 12-03-2005, 11:48 AM   #2
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 10,262
I'm not quite sure why you're posting your homework on the contests board... Consider this your lucky day.
Code:
for( e1 = start1, e2 = start2; e1 != e2; )
{
    while( e1 < e2 )
        e1 += increment1;
    while( e2 < e1 )
        e2 += increment2;
}
Yeah, that looks about right.


Quzah.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?

Last edited by quzah; 12-03-2005 at 11:50 AM. Reason: Lucky day.
quzah is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory problem with Borland C 3.1 AZ1699 C Programming 16 11-16-2007 11:22 AM
Someone having same problem with Code Block? ofayto C++ Programming 1 07-12-2007 08:38 AM
A question related to strcmp meili100 C++ Programming 6 07-07-2007 02:51 PM
WS_POPUP, continuation of old problem blurrymadness Windows Programming 1 04-20-2007 06:54 PM


All times are GMT -6. The time now is 08:39 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22