http://poj.org/problem?id=2017

按题意计算路程,直接算

View Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
int n,i;
int s[20],t[20];
int ans;
while(scanf("%d",&n),n!=-1)
{
for(i=0;i<n;i++)
scanf("%d%d",s+i,t+i);
ans=s[0]*t[0];
for(i=1;i<n;i++)
ans+=(t[i]-t[i-1])*s[i];
printf("%d miles\n",ans);
}
return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-07-07
  • 2021-07-22
  • 2021-12-05
  • 2021-12-10
  • 2021-12-07
猜你喜欢
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案