复制代码
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#include <cstdio> #include <cmath> using namespace std; int main(){ int s,x1,x2,t1,t2,p,d; while(~scanf("%d%d%d",&s,&x1,&x2)){ scanf("%d%d",&t1,&t2); scanf("%d%d",&p,&d); int tmp1,tmp2; tmp1 = abs(x2 - x1) * t2; if(d == 1){ if(p <= x1 && x2 > x1) tmp2 = (x2 - p) * t1; else if(x2 > x1) tmp2 = (s - p + s + x2) * t1; else if(x2 < x1) tmp2 = (s - p + s - x2) * t1; } else{ if(p >= x1 && x2 < x1) tmp2 = (p - x2) * t1; else if(x2 < x1) tmp2 = (p + s + s - x2) * t1; else if(x2 > x1) tmp2 = (p + x2) * t1; } if(tmp1 > tmp2) printf("%dn",tmp2); else printf("%dn",tmp1); } return 0; }
最后
以上就是优美钻石最近收集整理的关于CodeForces - 746C Tram的全部内容,更多相关CodeForces内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复