您的位置:首页 > 其它

CodeForces 816A Karen and Morning

2017-09-26 20:56 309 查看
CodeForces很良心,每个点都给数据,我已经不知道交了多少次了Orz

这题就是看错误点,慢慢加特判,一个一个加,最后总会A的(笑

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
const int maxn = 100010;
int h1, h2, m1, m2;
string h,m;
string time ,hour;
int main() {
char aaa;
string aa;
cin >> aa;
for(int i=0; i<5; i++) {
if(i<2)
h += aa[i];
else if (i>=3)
m += aa[i];
}
int mmz = (m[0] - '0') *10 + m[1]- '0';
int mmn = (m[1]- '0') *10 + m[0]- '0';
int hhz = (h[0]- '0') *10 + h[1]- '0';
int hhn = (h[1]- '0') *10 + h[0]- '0';
if(hhz == mmn) {
puts("0"); return 0;
}

if(mmz < hhn) {
if(hhn <= 60 && hhz!=6) {
cout << hhn - mmz;
return 0;
} else if(hhz==6){
int x = 60-mmz;
int y = (10 - hhz - 1) * 60;
cout << x+y+1;
} else if(hhz > 15 && hhz < 20) {
int x = 60-mmz;
int y = (20 - hhz - 1) * 60;
cout << x+y+2;
return 0;
} else if(hhz>=6&&hhz<10) {
int x = 60-mmz;
int y = (10 - hhz - 1) * 60;
cout << x+y+1;
return 0;
}
}
if(mmz > hhn && hhz !=23) {
if(hhz >= 15 && mmz > hhn && hhz<20) {
int x = 60-mmz;
int y = (20 - hhz - 1) * 60;
cout << x+y+2;
return 0;
}
if(hhz+1<6||hhz>=10) {
cout << 60-mmz+ (h[1]- '0'+1) *10 + h[0]- '0';
return 0;
}
if(hhz < 15) {
int x = 60-mmz;
int y = (10 - hhz - 1) * 60;
cout << x+y+1;
return 0;
}
}
if(hhz == 23){
cout << 60 - mmz;
return 0;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: