Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 16884 | Accepted: 11841 |
Description
Speed in miles perhour Total elapsed time in hours 20 2 30 6 10 7
Input
Output
Sample Input
3 20 2 30 6 10 7 2 60 1 30 5 4 15 1 25 2 30 3 10 5 -1
Sample Output
170 miles 180 miles 90 miles
Source
1 #include <iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 while(cin>>n) 9 { 10 if(n==-1) 11 break; 12 int sum = 0,time,speed,oldtime=0; 13 for(int i =0 ;i< n;i++) 14 { 15 scanf("%d%d",&speed,&time); 16 sum += (time-oldtime)*speed; 17 oldtime = time ; 18 } 19 cout<<sum<<" miles"<<endl; 20 } 21 }
原文:http://www.cnblogs.com/jhldreams/p/3761351.html