1. 

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #579 (ClockHands)
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/external/5/579.pdf
*
* @author Christian Posselt
* @author Jonathan Schubert
* @version 1.1, 04/30/2009
*
* Status : Accepted
* Runtime: 1.120
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Locale;
import java.util.StringTokenizer;

class Main
{
//Static arrays for precalculated angles
private static int[] mins = new int[60];
private static int[] hours = new int[13];

public static void main(String[] args) throws IOException
{
//precalculation of angles
for(int i = 0; i< 13; i++)
hours[i] = i*30;
for(int i = 0; i< 60; i++)
mins[i] = i*6;

BufferedReader Reader = new BufferedReader(new InputStreamReader(System.in));
StringBuilder bu = new StringBuilder();
int hour = 0;
int min = 0;

while(true)
{
//check for empty lines
String line = null;
do
{
line = Reader.readLine();
}while(line.isEmpty());

//Split input at :
StringTokenizer token = new StringTokenizer(line,": ");

while(token.hasMoreElements())
{
hour = Integer.parseInt(token.nextToken());
min = Integer.parseInt(token.nextToken());

if(hour == 0 && min == 0)
break;
double angleMin = mins[min];
double angleHour = hours[hour]+0.5*min;
double diffAngle = angleMin-angleHour;

//angle has to be within 0 and 180 degrees
if(diffAngle < 0 && diffAngle > -180)
diffAngle*=-1;
else if(diffAngle <= -180)
diffAngle+=360;
else if(diffAngle > 180)
diffAngle = 360-diffAngle;


//format String to 1/1000 accuracy
DecimalFormat form = (DecimalFormat)DecimalFormat.getInstance(Locale.ENGLISH);

form.applyPattern("0.000");
diffAngle=Math.round((1000*diffAngle))/(double)1000;
bu.append(form.format(diffAngle));
bu.append("\n");
}
if(hour == 0 && min == 0)
break;
}
System.out.print(bu.toString());
}
}

2.


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #579 - (ClockHands)
* http://icpcres.ecs.baylor.edu/onlinejudge/external/5/579.pdf
*
* @author Fabian Seidl
* @author Marcel Sachse
* @version 1.0, 04.05.2009
*
* Status :
* Runtime:
*/


import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {

public static void main(String[] args)
{
BufferedInputStream bin = new BufferedInputStream(System.in);
Scanner scanner = new Scanner(bin);

double angleH=0;
double angleM=0;
double angleDis=0;

String[] time =scanner.next().split(":");
int hour = Integer.parseInt(time[0]);
int minute = Integer.parseInt(time[1]);
while(hour!=0||minute!=0)
{
angleH=(hour*30)+(minute*0.5);
angleM=(minute*6.0);
if(angleM>angleH)angleDis=angleM-angleH;
else angleDis=angleH-angleM;
if(angleDis>180)angleDis=360-angleDis;
System.out.printf("%.3f%n",angleDis);

time =scanner.next().split(":");
hour = Integer.parseInt(time[0]);
minute = Integer.parseInt(time[1]);
}
}
}