import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); String[] a = in.nextLine().split(","); int one, sum, jl, qs, zd, q, w; int xs, fen, xs2, fen2; one = Integer.parseInt(a[0]); if (one < 3 || !isValidDate(a[1]) || !isValidDate(a[2])) { System.out.println("incorrect data"); } else { sum = one * 15; xs = Integer.parseInt(a[1].substring(11, 13)); fen = Integer.parseInt(a[1].substring(14, 16)); xs2 = Integer.parseInt(a[2].substring(11, 13)); fen2 = Integer.parseInt(a[2].substring(14, 16)); jl = (xs2 - xs) * 60 + fen2 - fen; qs = jl / sum + 1; zd = jl % sum; int which15 = (zd % 15==0)?zd/15:(zd/15+1) ; q = (which15 == one) ? 1 : (which15 + 1); w = (which15 == one) ? q : (zd % 15 == 0) ? q : (q + 1); System.out.println(qs + ";" + q + "-" + w); } } public static boolean isValidDate(String str) { boolean convertSuccess = true; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { format.setLenient(false); format.parse(str); } catch (ParseException e) { convertSuccess = false; } return convertSuccess; } }
点赞 评论

相关推荐

昨天 16:10
门头沟学院 Java
连笔试都没有就直接挂了&nbsp;这是学历厂吗两段大厂实习一段中厂一点机会都没有吗真的很难绷
xiaolihuam...:校招挂了,然后反手给我捞了个社招
投递虾皮信息等公司10个岗位
点赞 评论 收藏
分享
程序员小白条:这比例牛逼,750:1
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务