228527hu @ 2024-03-10 22:10:02
#include<stdio.h>
int main(){
int s,v;
scanf("%d %d",&s,&v);
int hour,minute;
hour=(s/v)/60;
if((s/v)%60==0)
minute=(s/v)%60;
else{
minute=(s/v)%60+1;
}
if(hour>=24)
return 0;
if(minute>50){
if(hour<=6){
printf("0%d:%d",6-hour,110-minute);
}
else if((30-hour)<10){
printf("0%d:%d",30-hour,110-minute);
}
else{
printf("%d:%d",30-hour,110-minute);
}
}
else{
if(minute<=40){
if(hour<=7){
printf("0%d:%d",7-hour,50-minute);
}
else if((31-hour)<10){
printf("0%d:%d",31-hour,50-minute);
}
else{
printf("%d:%d",31-hour,50-minute);
}
}
else{
if(hour<=7){
printf("0%d:0%d",7-hour,50-minute);
}
else if((31-hour)<10){
printf("0%d:0%d",31-hour,50-minute);
}
else{
printf("%d:0%d",31-hour,50-minute);
}
}
}
return 0;
}
by plokmnjiu @ 2024-03-10 22:52:48
#include<stdio.h>
int main(){
int s,v;
scanf("%d %d",&s,&v);
int hour,minute;
hour=(s/v)/60;
if((s/v)%60==0) // 建议用三目运算符,这样写太麻烦了
minute=(s/v)%60;
else{ // 奇怪的花括号,上面没有但是这里有
minute=(s/v)%60+1;
}
if(hour>=24) // 这完全没必要,难道是为了安全感么
return 0;
if(minute>50){ // 没有必要分情况这么细
// 这里太繁杂了,为什么一定要用printf?
// hour的正负问题完全可以这么写
/*
hour=6-hour,minute=110-minute;
if(hour<0)hour+=24;
if(hour<10)cout<<'0';
cout<<hour<<':'minute<<'\n';
*/
if(hour<=6){
printf("0%d:%d",6-hour,110-minute);
}
else if((30-hour)<10){
printf("0%d:%d",30-hour,110-minute);
}
else{
printf("%d:%d",30-hour,110-minute);
}
}
else{
// 重复的东西太多,把状态合并一些,下面完全是复制粘贴
// 先进行计算,负数就再加上一轮,有前导零就先输出
// 没有必要在计算之前就想好所有情况
if(minute<=40){
if(hour<=7){
printf("0%d:%d",7-hour,50-minute);
}
else if((31-hour)<10){
printf("0%d:%d",31-hour,50-minute);
}
else{
printf("%d:%d",31-hour,50-minute);
}
}
else{
if(hour<=7){
printf("0%d:0%d",7-hour,50-minute);
}
else if((31-hour)<10){
printf("0%d:0%d",31-hour,50-minute);
}
else{
printf("%d:0%d",31-hour,50-minute);
}
}
}
return 0;
}
by plokmnjiu @ 2024-03-10 22:55:18
虽然是橙题,但是写出了蓝题的气势