1.

/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11780 Miles 2 Km
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=117&page=show_problem&problem=2880
*
* @author Anton Pavlushko, IBB7B,
* @version 1.0, 29/11/2010
*
* Status : Accepted
* Runtime: 0.372
*/

import java.io.*;
import java.text.*;
import java.util.*;
public class Main {

private static int fibonaci [];

public static int get_id(int value,int length) {
for(int i=1;i<length;i++) if (Main.fibonaci[i]==value) return i;
return 0;
}

public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String current_line, empty = "";
int number, border, i, j, length, number_local;
Iterator iter;
NumberFormat f;
Formatter f1, f2, f3;
StringTokenizer input_string;
int count,n,k,array_length;
String predstavlenie, line_2;
float error, errors[];
float first, second;


try {

array_length=(int)Math.round(Math.log10(1000)/Math.log10(1.6))+2;

Main.fibonaci = new int[array_length];

Main.fibonaci[0]=1;
Main.fibonaci[1]=1;
for(i=2;i<array_length;i++) Main.fibonaci[i]=Main.fibonaci[i-1]+Main.fibonaci[i-2];

errors = new float[1001];
errors[1]=(float)0.4;
errors[2]=(float)0.2;
for(i=3;i<=1000;i++) {
error=(float)1.6*i;

for(j=1;j<i;j++) {
error=Math.min(error,errors[j]+errors[i-j]);
/* error=Math.min(error,Math.abs((float)1.6*i-((float)1.6*j+errors[j]+(float)1.6*(i-j)+errors[i-j])));
if (Main.get_id(j,array_length)>0)
error=Math.min(error,Math.abs((float)1.6*i-(fibonaci[Main.get_id(j,array_length)+1]+(float)1.6*(i-j)+errors[i-j]))); ;
if (Main.get_id(i-j,array_length)>0)
error=Math.min(error,Math.abs((float)1.6*i-(fibonaci[Main.get_id(i-j,array_length)+1]+(float)1.6*(j)+errors[j]))); ;
if (Main.get_id(j,array_length)>0 && Main.get_id(i-j,array_length)>0)
error=Math.min(error,Math.abs((float)1.6*i-(fibonaci[Main.get_id(i-j,array_length)+1]+fibonaci[Main.get_id(j,array_length)+1]))); ;
*/ }

if (Main.get_id(i,array_length)>0)
error=Math.min(error,Math.abs(fibonaci[Main.get_id(i,array_length)+1]-(float)1.6*i));
errors[i]=error;
}

while((current_line=in.readLine())!= null && !current_line.equals("0")) {
input_string = new StringTokenizer(current_line);
n=Integer.parseInt(input_string.nextToken());

predstavlenie="";
count=n;
error=0;
System.out.printf("%.2f%n",errors[n]);
/* while (count>0) {
for(i=0;i<array_length;i++) {
if (fibonaci[i]>count) {
predstavlenie+=fibonaci[i-1]+", ";
error+=0.625-fibonaci[i]/fibonaci[i-1];
count-=fibonaci[i-1];
break;
}
}
}
System.out.println(error+" ("+predstavlenie+")");
*/
// System.out.println(count);
}

} // end try
catch (IOException ee) {
System.err.println("Error: " + ee);
}
}
}


2.

/**
* FWP: Ausgewaehlte Probleme aus dem ACM (SS10)
*
* Problem: 11780 - Miles 2 Km
* Method: number theory
* Accepted: 0.288
* @author Evgeni Pavlidis
*
*/


import java.io.*;
import java.util.*;

class Main {

public static void main(String...args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

int m;
while( (m = Integer.parseInt(reader.readLine())) != 0)
System.out.printf("%.2f\n", Math.abs((m*1.6) - Math.round(m*1.6)) );
}
}