http://poj.org/problem?id=2017
1 #include<stdio.h> 2 int main() 3 { 4 int n,mile,hour; 5 while(~scanf("%d",&n)&&n!=-1) 6 { 7 int sum = 0,h = 0; 8 while(n--) 9 { 10 scanf("%d%d",&mile,&hour); 11 h = hour-h; 12 sum += mile*h; 13 h = hour; 14 } 15 printf("%d miles\n",sum); 16 } 17 return 0; 18 }