标签:注意 second image ++ example 分享图片 red content cond
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 500 Accepted Submission(s): 176
题意:给定一个时间作为起点,然后求下一个时针和分针的角度相差为k的时间。
【题意】
时间为12小时制。
告诉你一个时刻,让你输出在这个时刻之后的下一个时刻,
满足:该时刻,时针分针掐好相差某个的角度为a。
(注意,满足要求的时刻不一定是恰好以秒为单位,可以是秒与秒之间的时刻,我们可以向下取整)
【类型】
追及问题,判断
#include<stdio.h> #include<string.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<queue> #include<stack> #include<math.h> #include<vector> #include<map> #include<set> #include<cmath> #include<complex> #include<string> #include<algorithm> #include<iostream> #include<string.h> #include<algorithm> #include<vector> #include<stdio.h> #include<cstdio> #include<time.h> #include<stack> #include<queue> #include<deque> #include<map> #define inf 0x3f3f3f3f #define ll long long using namespace std; int main() { double h,m,s; char pp; int k=0; while(cin>>h>>pp>>m>>pp>>s) { k++; int a; cin>>a; double ah=h*30+m*0.5+s/120.0; while(ah>=360) ah-=360; double am=m*6+s/10.0; double x; if(am>=ah) { if(am-ah<=360-am+ah) { double o=am-ah; if(a>o) x=a-o; else x=360-o-a; } else { double o=360-am+ah; if(a>=o) x=o+a; else x=o-a; } } else { if(ah-am<=360-ah+am) { double o=ah-am; if(a<o) x=o-a; else x=a+o; } else { double o=360-ah+am; if(a>o) x=a-o; else x=360-a-o; } } x=x*120/11; int ss=(int)(s+x); int y=0; if(ss>=60) { y=ss/60; ss=ss%60; } int mm=m+y; y=0; if(mm>=60) { y=mm/60; mm=mm%60; } int hh=h+y; y=0; if(hh>=12) { hh=hh%12; } cout<<"Case #"<<k<<": "; printf("%02d:%02d:%02d\n",hh,mm,ss); } return 0; }
标签:注意 second image ++ example 分享图片 red content cond
原文地址:https://www.cnblogs.com/caiyishuai/p/9033637.html