72728abcd @ 2024-07-05 21:14:27
这是程序(新手,见谅)
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long S,v,t1,t21,t22;
cin>>S>>v;
if(S%v==0)
{
t1=S/v;
t1=t1%1440;
}
else
{
t1=S/v+1;
t1=t1%1440;
}
t22=(1920-t1-10)%60;
if(t1<480)
{
if((480-t1-10)/60<0)
{
for(;(1920-t1-10)/60>=24;t1+=1440)
{
t21=(480-t1-10)/60;
}
if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<24)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<24)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
else
{
for(;(1920-t1-10)/60<0;t1-=1440)
{
t21=(480-t1-10)/60;
}
if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
}
else if(t1<480)
{
t1+=1440;
if((480-t1-10)/60<0)
{
for(;(1920-t1-10)/60>=24;t1+=1440)
{
t21=(480-t1-10)/60;
}
if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<24)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((480-t1-10)/60<24)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
else
{
for(;(1920-t1-10)/60<0;t1-=1440)
{
t21=(480-t1-10)/60;
}
if((480-t1-10)/60<10)
{
t21=(480-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
}
else
{
if((1920-t1-10)/60<0)
{
for(;(1920-t1-10)/60>=24;t1+=1440)
{
t21=(1920-t1-10)/60;
}
if((1920-t1-10)/60<10)
{
t21=(1920-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((1920-t1-10)/60<24)
{
t21=(1920-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
else if((1920-t1-10)/60<10)
{
t21=(1920-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else if((1920-t1-10)/60<24)
{
t21=(1920-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
else
{
for(;(1920-t1-10)/60<0;t1-=1440)
{
t21=(1920-t1-10)/60;
}
if((1920-t1-10)/60<10)
{
t21=(1920-t1-10)/60;
if(t21<0)
{
for(int i=1;i;0)
{
if(t21<0)
{
t21+=24;
}
else
{
i=0;
}
}
}
if(t21<10)
{
if(t22<10)
{
cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<"0"<<t21<<":"<<t22<<endl;
}
}
else
{
if(t22<10)
{
cout<<t21<<":"<<"0"<<t22<<endl;
}
else
{
cout<<t21<<":"<<t22<<endl;
}
}
}
}
}
return 0;
}
by pi3_141592653589 @ 2024-07-05 21:25:02
看到代码长度的时候我沉默了......
by STA_Morlin @ 2024-07-05 21:26:23
这不会代码长度超长么()
by yangyang826 @ 2024-07-05 21:27:33
if 大佬
by pi3_141592653589 @ 2024-07-05 21:29:45
@72728abcd 其实很简单,只需要建立两个变量分别来存储小时数和分钟数即可,不过还需要特判小时数和分钟数是为零的情况,最后按要求输出就行了。
AC Code:(建议参考后自行写出)
#include <bits/stdc++.h>
using namespace std;
int s, v, h = 7, m = 50;
int main()
{
scanf("%d%d", &s, &v);
m -= ceil(s * 1.0 / v);
while (m < 0)
{
h -= 1;
m += 60;
}
while (h < 0)
{
h += 24;
}
printf("%.2d:%.2d\n", h, m);
return 0;
}
by Steve_xh @ 2024-07-05 21:42:50
@72728abcd 建议用 printf
格式化输出,起码每个位置能省 10 行
by jianglai0119 @ 2024-07-05 22:03:40
@72728abcd 代码拧巴,码风较旧,大佬勿喷
#include<bits/stdc++.h>
using namespace std;
int main(){
long long S,v,t1,t21,t22;
cin>>S>>v;
if(S%v==0)t1=S/v,t1=t1%1440;
else t1=S/v+1,t1=t1%1440;
t22=(1920-t1-10)%60;
if(t1<480){
if((480-t1-10)/60<0){
for(;(1920-t1-10)/60>=24;t1+=1440)t21=(480-t1-10)/60;
if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1; i; 0)
if(t21<0)t21+=24;
else i=0;
if(t21<10){
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
}else{
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}else if((480-t1-10)/60<24){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((480-t1-10)/60<24){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}else{
for(;(1920-t1-10)/60<0;t1-=1440)t21=(480-t1-10)/60;
if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1; i; 0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}
}else if(t1<480){
t1+=1440;
if((480-t1-10)/60<0){
for(;(1920-t1-10)/60>=24;t1+=1440)t21=(480-t1-10)/60;
if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((480-t1-10)/60<24){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10) cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((480-t1-10)/60<24){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}else{
for(;(1920-t1-10)/60<0;t1-=1440)t21=(480-t1-10)/60;
if((480-t1-10)/60<10){
t21=(480-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}
}else{
if((1920-t1-10)/60<0){
for(;(1920-t1-10)/60>=24;t1+=1440)t21=(1920-t1-10)/60;
if((1920-t1-10)/60<10){
t21=(1920-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
} else if((1920-t1-10)/60<24){
t21=(1920-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}else if((1920-t1-10)/60<10){
t21=(1920-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else if((1920-t1-10)/60<24){
t21=(1920-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}else{
for(;(1920-t1-10)/60<0;t1-=1440)t21=(1920-t1-10)/60;
if((1920-t1-10)/60<10) {
t21=(1920-t1-10)/60;
if(t21<0)
for(int i=1;i;0)
if(t21<0)t21+=24;
else i=0;
if(t21<10)
if(t22<10)cout<<"0"<<t21<<":"<<"0"<<t22<<endl;
else cout<<"0"<<t21<<":"<<t22<<endl;
else
if(t22<10)cout<<t21<<":"<<"0"<<t22<<endl;
else cout<<t21<<":"<<t22<<endl;
}
}
}
return 0;
}
by jianglai0119 @ 2024-07-05 22:06:11
本来的行数:671
现在的行数:217
本来的大小:9.05K
现在的大小:7.92K
by jianglai0119 @ 2024-07-05 22:07:46
其实我的代码也就23行
by jianglai0119 @ 2024-07-05 22:08:08
后来的代码 AC
by ab15801185281 @ 2024-07-06 11:24:15
@pi3_141592653589 671行