版本比较
题解:P14497 [NCPC 2025] Crochet Competition
正文
增加 9 行删除 9 行
123456718 行未改动2627282930313233346 行未改动41424344454647484950515253545556575859606136 行未改动9899100101102103104105# 题解:P14497 [NCPC 2025] Crochet Competition这个题只需要把给定的起始时间换成时间戳,相减后在转化为天时分的顺序有一个细节是如果开始结束时间戳分别是 $s$ 与 $t$,当 $t$ 大于 $s$ 时直接用 $t$ 减 $s$,但在 $t<s$ 时,也就是不在一周内时,把 $t$ 直接加上一周的时间,而不能直接 $s$ 减 $t$代码:18 行未改动void wm(int p){cout<<p<<" minute";if(p>1) cout<<"s";}//加复数形式signed main(){ios::sync_with_stdio(false);cin.tie(0);6 行未改动ma["Sun"]=6;cin>>x>>hh>>kkk>>mm;s=ma[x]*60*24+hh*60+mm;cin>>x>>hh>>kkk>>mm;t=ma[x]*60*24+hh*60+mm;//转化时间戳if(s==t)//相等输出7天{cout<<"7 days"<<endl;return 0;}if(t<s) t+=7*60*24;//不在同一周int d,n,m=t-s;d=m/(60*24);m-=d*60*24;h=m/60;m-=h*60;//转化if(d&&h&&m)//分类讨论{wd(d);cout<<", ";wh(h);36 行未改动{wm(m);cout<<"\n";}return 0;}```123456718 行未改动2627282930313233346 行未改动41424344454647484950515253545556575859606136 行未改动9899100101102103104105# 题解:P14497 [NCPC 2025] Crochet Competition这个题只需要把给定的起始时间换成时间戳,相减后在转化为天时分的顺序有一个细节是如果开始结束时间戳分别是 $s$ 与 $t$,当 $t$ 大于 $s$ 时直接用 $t$ 减 $s$,但在 $t<s$ 时,也就是不在一周内时,把 $t$ 直接加上一周的时间,而不能直接 $s$ 减 $t$代码:18 行未改动void wm(int p){cout<<p<<" minute";if(p>1) cout<<"s";}//加复数形式signed main(){ios::sync_with_stdio(false);cin.tie(0);6 行未改动ma["Sun"]=6;cin>>x>>hh>>kkk>>mm;s=ma[x]*60*24+hh*60+mm;cin>>x>>hh>>kkk>>mm;t=ma[x]*60*24+hh*60+mm;//转化时间戳if(s==t)//相等输出7天{cout<<"7 days"<<endl;return 0;}if(t<s) t+=7*60*24;//不在同一周int d,n,m=t-s;d=m/(60*24);m-=d*60*24;h=m/60;m-=h*60;//转化if(d&&h&&m)//分类讨论{wd(d);cout<<", ";wh(h);36 行未改动{wm(m);cout<<"\n";}return 0;}```