赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1. 简单题


#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int n, i, ans, t[11], s;
    while (cin >> n)
    {
        if (n == -1)
            break;
        memset(t, 0, sizeof(t));
        ans = 0;
        for (i = 1; i <= n; i++)
        {
            cin >> s >> t[i];
            ans += s * (t[i] - t[i-1]);
        }
        cout << ans << " miles" << endl;
    }
    return 0;
}


posted on 2012-03-29 14:49  赵乐ACM  阅读(189)  评论(0编辑  收藏  举报