Please help in this easy hackerrank problem

Правка en1, от acash, 2019-06-24 18:04:54

input:

10 1 2

1

100

debug val 1 and debug val 2 are printing are same but req which is equal to (debug val 1 — debug val 2) is not getting zero ?

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int l,s1,s2;
    cin>>l>>s1>>s2;
    int q;
    cin>>q;
    long long int relspe = abs(s2-s1);
    while(q--){
        long long int a;
        cin>>a;
        cout<<"debug val 1  "<<sqrt(2)*l<<endl;
        cout<<"debug val 2 "<<sqrt(2)*sqrt(a)<<endl;
        double req = abs(sqrt(2)*l-sqrt(2)*sqrt(a));
        cout<<"req "<<req<<endl;
        double ans = req/relspe;

        cout<<ans<<endl;
    }
}

https://www.hackerrank.com/challenges/sherlock-and-moving-tiles/problem

Теги #algorithms

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский acash 2019-06-24 18:04:54 873 Initial revision (published)