日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > 綜合技術(shù) > Codeforces Round #386 (Div. 2) C. Tram 數(shù)學(xué)、討論

Codeforces Round #386 (Div. 2) C. Tram 數(shù)學(xué)、討論

來源:程序員人生   發(fā)布時間:2017-02-24 10:43:22 閱讀次數(shù):3238次

C. Tram
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x?=?0 and x?=?s.

Igor is at the point x1. He should reach the point x2. Igor passes 1 meter per t2 seconds.

Your task is to determine the minimum time Igor needs to get from the point x1 to the point x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point x1.

Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than 1 meter per t2 seconds). He can also stand at some point for some time.

Input

The first line contains three integers sx1 and x2 (2?≤?s?≤?10000?≤?x1,?x2?≤?sx1?≠?x2) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to.

The second line contains two integers t1 and t2 (1?≤?t1,?t2?≤?1000) — the time in seconds in which the tram passes 1 meter and the time in seconds in which Igor passes 1 meter.

The third line contains two integers p and d (1?≤?p?≤?s?-?1d is either 1 or ) — the position of the tram in the moment Igor came to the point x1 and the direction of the tram at this moment. If , the tram goes in the direction from the point s to the point 0. Ifd?=?1, the tram goes in the direction from the point 0 to the point s.

Output

Print the minimum time in seconds which Igor needs to get from the point x1 to the point x2.

Examples
input
4 2 4
3 4
1 1
output
8
input
5 4 0
1 2
3 1
output
7
Note

In the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass 2 meters and it takes 8 seconds in total, because he passes 1 meter per 4 seconds.

In the second example Igor can, for example, go towards the point x2 and get to the point 1 in 6 seconds (because he has to pass 3meters, but he passes 1 meters per 2 seconds). At that moment the tram will be at the point 1, so Igor can enter the tram and pass 1meter in 1 second. Thus, Igor will reach the point x2 in 7 seconds in total.




Source

Codeforces Round #386 (Div. 2)


My Solution

題意:從x1 動身到 x2,走路速度是t2 s/ 單位長度 ,坐車是t1 s/ 單位長度,車子在0~s間不斷來回,此時車在p位置,且方向是d,(正向 d == 1,反向 d == ⑴) 問從x1到x2的最短時間


數(shù)學(xué)、討論

另外題可以分成2大類,到達(dá)的時候是走路的則只斟酌全走路,如果到達(dá)的時候是坐車則只斟酌坐車,

即x1到達(dá)x2所花的時間為此時p位置到最后以x1指向x2的方向經(jīng)過x2時的總時間。

具體分成以下6類討論

     當(dāng) x1 < x2 時
        ans = (x2 - x1) * t2;
        if(d == 1){
            if(p <= x1){                //p 在 x1、 x2 左側(cè)邊
                ans = min(ans, (x2 - p) * t1);
            }
            else{
                ans = min(ans, (s + x2 + s - p) * t1);
            }
        }
        else{
            ans = min(ans, (p + x2) * t1);
        }
    
    當(dāng) x1 > x2 時
        ans = (x1 - x2) * t2;
        if(d == 1){
            ans = min(ans, (s - p + s - x2) * t1); //
        }
        else{
            if(p >= x1){                //p 在 x1、 x2 右側(cè)
                ans = min(ans, (p - x2) * t1);
            }
            else{
                ans = min(ans, (p + s + s - x2) * t1);
            }
        }
    


#include <iostream>
#include <cstdio>

using namespace std;
typedef long long LL;
const int maxn = 1e6 + 8;


int main()
{
    #ifdef LOCAL
    freopen("c.txt", "r", stdin);
    //freopen("c.out", "w", stdout);
    int T = 4;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);

    LL s, x1, x2, t1, t2, p, d, ans = 9e18;
    cin >> s >> x1 >> x2;
    cin >> t1 >> t2;
    cin >> p >> d;
    if(x1 < x2){
        ans = (x2 - x1) * t2;
        if(d == 1){
            if(p <= x1){
                ans = min(ans, (x2 - p) * t1);
            }
            else{
                ans = min(ans, (s + x2 + s - p) * t1);
            }
        }
        else{
            ans = min(ans, (p + x2) * t1);
        }
    }
    else{
        ans = (x1 - x2) * t2;
        if(d == 1){
            ans = min(ans, (s - p + s - x2) * t1); //(©D£?©D)
        }
        else{
            if(p >= x1){
                ans = min(ans, (p - x2) * t1);
            }
            else{
                ans = min(ans, (p + s + s - x2) * t1);
            }
        }
    }

    cout << ans << endl;

    #ifdef LOCAL
    cout << endl;
    }
    #endif ** LOCAL
    return 0;
}



  Thank you!

                                                                                                                                               ------from ProLights

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 日日夜夜天天干 | 三级福利 | 日韩小视频 | 天堂аⅴ在线最新版在线 | 精品嫩草| 欧美三区视频 | 国产精品一区二区不卡 | 国产一二区在线 | 一区二区中文 | 欧美aa在线观看 | 亚洲国产黄色 | 国产精品亚洲第一 | 男女国产视频 | 99国产精品久久久久久久久久 | 久久久久久久久国产 | 狠狠淫xx| 欧美成人国产va精品日本一级 | 国产精品久久久久久久免费大片 | 俄罗斯a级毛片 | 国产麻豆一区二区三区在线观看 | 中字一区 | 国产xxxx视频 | 亚洲在线免费观看 | 黄色小视频在线免费观看 | 国产精品久久久久久久午夜 | 欧美日韩在线免费 | 亚洲国产精品久久久久久 | 欧美三级黄色大片 | 黄网视频在线观看 | 一级黄色大片 | 国产一区二区免费看 | 亚洲一区在线免费 | 91久久国产综合久久91精品网站 | 91视频在线网址 | av在线a| 日韩精品一区二区三区中文在线 | 九九久久99| 色婷婷免费观看 | 男操女视频网站 | 国产在线自 | 日韩精品在线播放 |