题目描述
1.注意0和O的区别
2.情况要讨论清楚
3。分钟大于60记得进一
样例
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
int x,y;
cin>>a>>b>>c>>d;
if(a<c){
x=(c*60+d-(a*60+b))/60;
y=(c*60+d-(a*60+b))%60;
cout<<"O JOGO "<<"DUROU "<<x<<" HORA(S) E "<<y<<" MINUTO(S)"<<endl;
}else if(a==c&&b==d){
printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
}else if(a==c&&b<d){
printf("O JOGO DUROU 0 HORA(S) E %d MINUTO(S)\n",d-b);
}
else{
x=(23-a+c);
y=d+60-b;
if(y>60){
x=x+1;
y=y-60;
}
cout<<"O JOGO "<<"DUROU "<<x<<" HORA(S) E "<<y<<" MINUTO(S)"<<endl;
}
return 0;
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla