PROBLEM LINK:Author: Yuri Shilyaev DIFFICULTY:CAKEWALK PREREQUISITES:Equation of uniform motion. PROBLEM:You are given two variants of route, one with length equal to $sqrt(2) * N$ and maximal velocity $V_1$, and another with length equal to $2 \cdot N$ and maximal velocity $V_2$. You have to find which route will use less time. QUICK EXPLANATION:$S = v * t$, so just calculate time of both routes. EXPLANATION:Time of the first route is $T_1 = \frac{sqrt(2) * N}{ V_1}$. Time of the second $T_2 = \frac{2 * N}{V_2}$. $T_1$ ? $T_2$ $V_2 * sqrt(2)$ ? $V_1 * 2$ $V_2$ ? $V_1 * sqrt(2)$ So, the first route is faster if $V_2 < V_1 * sqrt(2)$. Why the times couldn't be equal? Imagine that $V_2 = V_1 * sqrt(2)$. $V_2$ is integer, while $V_1 * sqrt(2)$ is irrational. Obviously, they can't be equal. AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution can be found here. RELATED PROBLEMS:
This question is marked "community wiki".
asked 20 Aug '17, 18:22

include <iostream>include<cmath>include<string>using namespace std; int main() { int t,n,v1,v2; string str1="Elevator"; string str2="Stairs"; cin>>t; while(t) { cin>>n>>v1>>v2; if(v2>(v1*sqrt(2))) cout<<str1<<"\n"; else cout<<str2<<"\n"; }strong text
} answered 21 Aug '17, 07:57

//package codechef4; import java.io.; import java.util.; class Solution {
} answered 29 Aug '17, 00:09

include <iostream.h>using namespace std; int main() { cout<<"hey"; return 0; } answered 07 Sep '17, 19:11

Hi I'm new to code chef recently joined. I'm trying to solve the elevator problem .Howeve rwhen I submit I keep getting wrong answer error. Please help!! here's my code:
int distance = 0, vel1 = 0, vel2 = 0; float time1 = 0 ,time2 =0; //Enter Distance, velocity of elevator and stairs scanf("%d %d %d",&distance,&vel1,&vel2); /if vel1>vel2 i.e velocity of stairs velocity of Elevator automatically display stairs since 1.41Distance < 2Distance/ if(vel1 >= vel2){ printf("Stairs"); return(0); } time1 = (sqrt(2) * distance)/ (float) vel1; time2 = (2*distance)/(float) vel2; //convert to float //Check for least time if(time1 <time2) printf("Stairs"); else printf("Elevator"); return(0); } answered 20 Feb '18, 15:52
