Problem Link : http://www.codechef.com/problems/HS08TEST
Solution :
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author XCoder
*/
class ATM {
public static void main(String[] args) throws IOException {
String s = br.readLine();
float towithdraw = Float.parseFloat(s.split(" ")[0]);
float totbal = Float.parseFloat(s.split(" ")[1]);
if (towithdraw % 5 == 0 && (towithdraw+0.5) <= totbal) {
String f=String.format("%.2f", totbal - towithdraw - 0.5);
System.out.println(f);
}else{
String f=String.format("%.2f", totbal);
System.out.println(f);
}
}
private static BufferedInputStream bis = new BufferedInputStream(System.in);
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static int readIntLine() throws IOException {
return Integer.parseInt(br.readLine());
}
public static long readLongLine() throws IOException {
return Long.parseLong(br.readLine());
}
}
No comments:
Post a Comment