In a 12-hour clock, there are minute hand, hour hand, and second hand to indicate time. The angle between the minute hand and the hour hand is A (0≤A≤180), and the angle between the minute hand and the second hand is (0≤B≤180). And exactly at ss hour ff minute mm second, the conditions A=2 BA=2B and 0≤s≤6;0≤f<60;0≤m<60 are met. What are s, f, ms, f, and m respectively? How many.
Please find a solution other than 0 hours, 0 minutes and 0 seconds.
Note that the hour hand, minute hand, and second hand all rotate uniformly around the center.
The submission format is three integers separated by a space, representing s, f, ms, f, m respectively. For example, 31158 means 3:11:58.
public class 钟表 { /** * 模拟问题:模拟现实生活中的真实场景 * 本题:分析时针、分针、秒针的转动规律 和 两两之间的对应关系 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //枚举时,分,秒 double sd,md,hd; for(double s=0;s<60;s++) {//秒 sd=360*s/60; for(double m=0;m<60;m++) {//分 md=360*m/60; md+=6*s/60; for(double h=0;h<=6;h++) {//时 hd=360*h/12; hd+=30*(m*60+s)/3600; double A=Math.abs(md-hd);//为符合题目角的范围,避免是优角 A=Math.min(A, 360-A); double B=Math.abs(md-sd); B=Math.min(B, 360-B); if (A==2*B) { System.out.println((int)h+" "+(int)m+" "+(int)s); } } } } } }
blue bridge cup clock
Guess you like
Origin blog.csdn.net/weixin_65528063/article/details/130874062
Recommended
Ranking