微博上有個自稱“大笨鐘V”的傢伙,每天敲鐘催促碼農們愛惜身體早點睡覺。不過由於笨鍾自己作息也不是很規律,所以敲鐘並不定時。一般敲鐘的點數是根據敲鐘時間而定的,如果正好在某個整點敲,那麼“當”數就等於那個整點數;如果過了整點,就敲下一個整點數。另外,雖然一天有24小時,鍾卻是隻在後半天敲1~12下。例如在23:00敲鐘,就是“噹噹噹噹噹噹噹噹噹噹噹”,而到了23:01就會是“噹噹噹噹噹噹噹噹噹噹噹噹”。在午夜00:00到中午12:00期間(端點時間包括在內),笨鍾是不敲的。
下面就請你寫個程序,根據當前時間替大笨鐘敲鍾。
輸入格式:
輸入第一行按照hh:mm
的格式給出當前時間。其中hh
是小時,在00到23之間;mm
是分鐘,在00到59之間。
輸出格式:
根據當前時間替大笨鐘敲鍾,即在一行中輸出相應數量個Dang
。如果不是敲鐘期,則輸出:
Only hh:mm. Too early to Dang.
其中hh:mm
是輸入的時間。
輸入樣例1:
19:05
輸出樣例1:
DangDangDangDangDangDangDangDang
輸入樣例2:
07:05
輸出樣例2:
Only 07:05. Too early to Dang.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
//** Class for buffered reading int and double values *//*
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
// ** call this method to initialize reader for InputStream *//*
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
// ** get next word *//*
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
// TODO add check for eof if necessary
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static boolean hasNext()throws IOException {
return tokenizer.hasMoreTokens();
}
static String nextLine() throws IOException{
return reader.readLine();
}
static char nextChar() throws IOException{
return next().charAt(0);
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static float nextFloat() throws IOException {
return Float.parseFloat(next());
}
}
public class Main {
public static void main(String[] args) throws IOException {
Reader.init(System.in);
String s = Reader.nextLine();
String[]t = s.split(":");
int hour = Integer.parseInt(t[0]);
int minute = Integer.parseInt(t[1]);
if (hour*60+minute<=12*60) {
System.out.println("Only "+String.format("%02d", hour)+":"+String.format("%02d", minute)+". Too early to Dang.");
} else {
int n = (int) Math.ceil((hour*60+minute)/60.0)-12;
for (int i = 0; i < n; i++) {
System.out.print("Dang");
}
}
}
}