This problem contains one unobvious and unpleasant trick. In statement it is said that result must be output with "accuracy to 0.0001". But in fact you must output result rounded up to fourth digit after decimal point. So, if you output answer with some additional precision, you'll get WA. For example, I got "Accepted" when corrected line writeln (finres:0:5); to writeln (finres:0:4); in my program.