【ACM打卡】2176

2176

求路程。

总路程=(t1-t0)*x1+....(tn-tn-1)*xn

运用时间段求。共有n组时间段,当n=-1时,跳出循环。


(很久没做题了!!!不能再这样了!!!100个啊!!!导师又在点我们了!!!科目三gogogo 单词gogogo 拉丁课gogogo 少吃gogogo 学化妆gogogo 做题gogogo微笑微笑微笑


2176

#include<iostream>
using namespace std;

int main(){
    int n;
    while( cin>>n && n!=-1 ){
        int s,t,p=0,distance=0;

        while( n-- && cin>>s>>t ){
            distance += s*(t-p);
            p = t;
        }
        cout<<distance<<" miles"<<endl;
    }
    return 0;
}


posted @ 2015-02-05 00:37  怡人Iris  阅读(90)  评论(0编辑  收藏  举报