# Sherlock and Moving Tiles

atique + 2 comments Query has double type input instead of integer. This is not matching problem description. That's bad. That is why statistics of the problem shows less acceptance. Please fix.

GustavBertram + 3 comments Actually, it just doesn't fit inside an int. It's all there in the problem statement. q <= L^2 and L<=10^9, so q<=10^18. LONG_MAX in this environment is 9223372036854775807, so that is juuuust sufficient.

masotrix + 0 comments You are the one right man.

atique + 0 comments I am sorry. I made wrong guess. You are right.

sgrebenkin + 0 comments Yeah. Use long.

- SX
StoneCold_Xi + 0 comments [deleted]

- JH
protojas + 3 comments For python users having trouble with JUST number 4 - try doing

`format(answer, '.20f')`

to get the right precision required.

dbhrockzz + 2 comments import math l,s1,s2 = map(int,raw_input().split()) n = input() q = [] for i in range(n): q.append(input()) rel = abs(s1*math.sin(math.radians(45))-s2*math.sin(math.radians(45))) for qi in q: if qi==(l**2): print 0.0000000 else: print format((l-math.sqrt(qi))/rel,'.20f')

Test Case 4 is still coming wrong

jane_beguin + 0 comments with this code you have O(1) complexity and it works

import math t, v1, v2 = map(int, input().split()) for _ in range(int(input())): a = int(input()) rep = math.sqrt(2)*(t-math.sqrt(a))/abs(v2-v1) print (rep)

sgrebenkin + 0 comments Oh c'mon, sin(Pi/4) = sqrt(2)/2;

- SM
bigbang1498 + 1 comment Can you please explain the logic behind using format here, I wasn't getting 4th testcase right but after doing what you suggested I got it right

- JH
protojas + 1 comment I noticed that for people using C++ they were having precision errors.

`format(answer, .20f)`

just makes the answer go to 20 decimal points, which is somehow required for question 4.. not sure why though- SM
bigbang1498 + 0 comments thanks

RahulHP + 0 comments Thanks a lot, I wasted a submission due to this before reading your comment!

tvanloon + 4 comments For those using C++ stuck on test cases 3 and 4, use cout << std::fixed <<

- VB
withasingle_t + 0 comments Thanks!

- KW
q1a2z3 + 0 comments What does that do?

adarsh97 + 0 comments you are awesome bro....very very thank you.

metamemelord + 0 comments cout<<setprecision(50)<<ans<<endl;

works as well!

- MC
manish_chauhan + 1 comment i m not getting it can someone explain me logic of this progam

JasolAsked to answer + 1 comment Hm, doesn't look like I can paste a picture in here, but I'll try to give you some information that helped me. You're trying to solve for time, so you want an equation with time where you can isolate time, and solve it. Distance = speed x time. There are two distances available to you, the distances of the bottom left corner of both squares. Using this information, and the picture provided with the problem, you can solve for time.

- B
bismitapadhy + 0 comments I am not able to understand the question exactly.can you please explain

- SK
subash_kotha2 + 1 comment Working C++ Code

#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { double l,s1,s2; cin>>l>>s1>>s2; int q;cin>>q; do{ double area; cin>>area; if(area<=l*l) { cout<<(sqrt(2)*((double)l-sqrt(area)))/abs(s1-s2)<<endl; } else cout<<0<<endl; q--; }while(q!=0); }

shahalamansari98 + 0 comments could you please explain the code?

pl_lepko + 0 comments I solved this problem by solving: Quadratic equation...

q= ( L+(time*p)) * (L+(time*p)); (L+t*p) * (L+t*p) = q q = L^2 + 2*L*t*p + t^2*p^2; q - L^2 = 2*L*t*p + t^2*p^2; q - L^2 = 2*L*t*p + t^2*pS; (a)*t^2 + (b)*t - (c) = 0; //quadratic equation....

masterpradeep + 9 comments Getting runtime error for testcases 4,5,6. suceesfully executed 1,2,3.How to find out the reason for run time error. Help

public class Solution {

`public static void main(String[] args) { Scanner g=new Scanner(System.in); int side=g.nextInt(); int v1=g.nextInt(); int v2=g.nextInt(); double a = Math.sqrt(2); double diagonal=a * side; int v3=Math.abs(v1-v2); int t=g.nextInt(); for(int i=0;i<t;i++) { int distance=g.nextInt(); double diagonal2=a * Math.sqrt(distance); if(v3 != 0) { double result = (Math.abs(diagonal-diagonal2))/v3; System.out.println(result); } else { System.out.println(0.00000000000000); } } }`

}

masterpradeep + 0 comments Solved it by using - nextDouble()

- R
romario_yakunin + 0 comments This problem is sopposed to be solved with a formula.

cgira + 0 comments try changing your else statement to return infinity instead of 0.0. The logic is that if the two squares move at a same pace, they will never leave q area as shown on the picture

pGxplorer + 0 comments no need to write else part. It is already said that S1 and S2 will

**never**be equal.vvbhandare + 0 comments Will you please explain how you calculate this to get q? I tried to understand your code but could not get it.

- TM
ThanujaM + 0 comments Use long for v1,v2 and v3

ebrucecfa + 0 comments U should use

double distance=in.nextDouble();

int will result in Test Case failures in Java8.

bhuvanms + 1 comment why are we doing s1-s2 relative velocity concept??

- RS
rajatsaini + 0 comments Relative velocity will give us the speed of (original_diagonal - diagonal_of_qi).

- VP
poonia0312 + 0 comments hello your code give runtime error in testcase 3,4,5 plz correct it

- ì¤‘Y
a01071846617 + 0 comments numer 3,4,5 wrong answer

`vector<double> result; for(int i=0;i<queries.size();i++) { if(s1>s2) { result.push_back(((sqrt((double)queries[i])-l)*sqrt((double)2))/(s2-s1)); } else { result.push_back(((sqrt((double)queries[i])-l)*sqrt((double)2))/(s1-s2)); } } return result; why........ teach me please....`

Sort 149 Discussions, By:

Please Login in order to post a comment