点击打开链接
//t1<t2时:要么直接走到 要么坐车到
//因为坐车第k次经过x2的时间是固定的,所以上车前走了多少步是不重要的.
//人选择坐车时,车要经过x1,人才有可能上车
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#include <bits/stdc++.h> using namespace std; const int N=2e4+20; int main() { int s,x1,x2,t1,t2,p,d; while(cin>>s>>x1>>x2>>t1>>t2>>p>>d) { if(t2<=t1) { cout<<abs(x2-x1)*t2<<endl;; } else { int ans=abs(x2-x1)*t2;//by foot int res=0;//by car bool flag=false; //x1,x2,p位置情况比较多,但是s<=1000 一步一步模拟即可 while(1) { if(p==x1) flag=true; if(p==x2&&flag) break; //掉头 if(p==0&&d==-1) d=1; if(p==s&&d==1) d=-1; p+=d;// res+=t1; } cout<<min(res,ans)<<endl; } } return 0; }
最后
以上就是忐忑百合最近收集整理的关于Codeforces 746C Tram 模拟+思维的全部内容,更多相关Codeforces内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复