They are given in degrees, not in radians.
Awesome.
Lat/long are given in radians, not in degree as said MrAnderson
Thx!
I found my mistake ⊠it took me a while and so obvious !!!
I hate myself in these case
Bless u sir.
[solved]
Hi,
I have got a mistake for test number 3âŠ
I found nearest âCaisse dâassurance retraite et de la Sante au travailâ (distance=0.0218670137907) than âCaisse Primaire dâAssurance Maladieâ (distance=0.0329447601689)
the test #1 2 and 4 are ok but this doesnât workâŠ
Iâm with python
Have you got an idea for my problem ?
Thanks a lot
I found the problem in my formula for distance.
Hello tous le monde !
Jâai bien aimĂ© ce puzzle mais je vous conseil de ne pas prendre la formule donnĂ© dans lâĂ©noncĂ© pour le calcul de distance car perso câest ce qui faisait buger la pgâŠ
Mais plutĂŽt celle ci
d = R.acos(sin(a).sin(b)+cos(a).cos(b).cos(c-d))
Elle fait peur certe fonctionne trĂšs bien et le must câest que cela se fait en une Ă©tape et pas trois !
a = Lat A
b = Lat B
c = Long A
d = Long B ----- Bien sur toutes ces donnĂ©es sont quand mĂȘme a rentrĂ© en radians
I had the same problem. donât use the provided triangulation formula. Simplify it :
Sqrt((LON1 - LON2)^2 + (LAT1 - LAT2)^2)
That fixed may problems. I was using doubles in C#.
JavaScript.
I have an issue where I pass all test cases in the IDE, but then when I submit I fail on âComplete fileâ. I canât figure it out why. Is anyone here able to help?
const radCon = (180 / Math.PI)
const LON = readline().replace(',','.') * radCon;
const LAT = readline().replace(',','.') * radCon;
const N = +(readline());
let shortestDistance = Infinity;
let nameOfShortest = '';
for (let i = 0; i < N; i++) {
let [,name,,, long, lat] = readline().split(';');
long = long.replace(',', '.') * radCon;
lat = lat.replace(',', '.') * radCon;
x = (long - LON) * Math.cos((LAT + lat) / 2);
y = lat - LAT;
distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
if (distance <= shortestDistance){
shortestDistance = distance;
nameOfShortest = name;
}
}
print(nameOfShortest);
DO NOT forget to add â.0â at the end of numbers when computing with floats or doubles !
The debugger in the browser doesent seem to want to replace commas with dots. So i cant parse the strings to doubles and my whole algorithm doesent work. Feelsgood when you cant even test your code.
In Java, replace returns a new String, it doesnât modify the current String.
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace(char,%20char)
actually, you can check the first pitfall of this playground: https://tech.io/playgrounds/1097/the-most-common-java-pitfalls
Input values - that includes lat lng of User (first and second line of input) and not only - as I assumed - data for defribillators. Many minutes were lost
Thanks for the hint
Mate, you saved me so many hours here! Ty a lot!
I dont get it inside the IDE all test work with sucess. when i submit the
âsingle possibilityâ test appear as Red. Why??? 0.o
StrangeâŠ
In VS my code works correct, but in website - wrong.
Website cannot round a double value with many digits after â , 'âŠ
Iâve tried Math.Round, but it doesnât work
Bonjour,
jâai fini lâexercice mais lorsque je soumets mes rĂ©sultats, lâexercice n°3 nâest pas acceptĂ©.
Jâai changĂ© mon code plusieurs fois mais rien ne change, pouvez-vous me conseiller?
Well, the same old song - program passed all testcases in IDE, but failed on âComplete file 2â on Submit. Iâve tried all recomended - using different formulas, removing converting from degrees to rads, changing double to long double but nothing helped. And CG doesnât give any clue what goes wrong. Thanks for killing my motivation
Understand. It was timeout problem. After some optimization of my code (C++) it passed. But I still think, that CG should tell the type of error - e. g. âtimeout errorâ or âwrong answerâ or something like this
Iâm surprised that test set allow passing with wrong formulae. Iâve misspelled some part of it and was ok, other people simplify formula, some of them even overlook to convert to radians⊠Maybe add some test cases with points far away, to make errors be visible?