![]() |
| | #1 |
| Registered User Join Date: May 2005
Posts: 76
| Problem - 2 elevators, when do they meet ? 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 | |
| | #2 |
| +++ OK NO CARRIER 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;
}
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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |