1.
/**
* Angewandte Mathematik, SS11
* Problem: 10784 Diagonal
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=19&problem=1725
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 20/5/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.232
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String inputLine="";
int counter =1;
while((inputLine = reader.readLine())!= null)
{
long input = new Long(inputLine);
if(input==0) break;
System.out.println("Case "+counter+": "+(long) Math.ceil((3.0 + Math.sqrt(9.0 + (input*8.0)))/2.0));
counter++;
}
}
}

--------------------------------------------------------


1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10784 Diagonal
*
* @author Robert Reichart
*
* Status : Accepted
* Runtime: 0.212
*/

import java.io.*;

class Main{
public static void main(String... args)throws IOException{
BufferedReader is= new BufferedReader(new InputStreamReader(System.in));
long wert = 0;
long count =0;

while(true){
String line=is.readLine();

if (line!=null && !line.equals("")){
if (line.equals("0")){break;}
wert=Long.parseLong(line);
count++;
long result =(long)(Math.ceil((3 + Math.sqrt((9 +8*wert))) / 2));

System.out.println("Case " + count + ": " + result);


}
}
}
}