|
|
back to boardWhat if use integers instead of float? Posted by SPIRiT 22 Aug 2006 13:05 I read every line containing a number. And after that simply read all digits (without a point) and convert into integer 1 cm=1. 100km=100*10^3m=100*10^5cm=10^7. In that range I use binary search for finding the maximum possible length. Why WA at test 1? (Yeah, I sort the lens too) Here is a sample of code for converting: fgets(buf,150,INPUT_STREAM); tmp=0; j=0; while((buf[j]>='0'&&buf[j]<='9')||buf[j]=='.') { if(buf[j]!='.')tmp=tmp*10+buf[j]-'0'; j++; } sum+=tmp; Lens[i]=tmp; Do the lengths always have exactly two digits Edited by author 22.08.2006 13:44 Re: What if use integers instead of float? Posted by Sid 22 Aug 2006 21:37 In fact you are right, you are to use in this problem integers instead of float and binary search. If you have wa#1 probaly you didn't understand problem... I got AC without a sort... Posted by SPIRiT 23 Aug 2006 16:05 When I removed sorting the lens and set the right bound to 100 km (not to the maximal length possible), I've got AC. Can anyone explain why? This two features were just for speed, they don't change the idea of binary search itself, I still used it. What could be wrong? |
|
|