acm 1007 接力问题
来源:互联网 发布:马桶推荐 知乎 编辑:程序博客网 时间:2024/04/30 08:31
1.1007
2.
You have to process several teams. For each team you are given a list with the running times for every section of the race. You are to compute the average time per kilometer over the whole distance. That's easy, isn't it?
So if you like the fun and challenge competing at this contest, perhaps you like a relay race, too. Students from Ulm participated e.g. at the "SOLA" relay in Zurich, Switzerland. For more information visit http://www.sola.asvz.ethz.ch/ after the contest is over.
2[bk]12.5[bk][bk]5[bk]0:23:21[bk]0:25:01[bk]42[bk]0:23:32[bk]-:--:--[bk][bk]7[bk]0:33:20[bk]0:41:35
[bk][bk]5:[bk]3:52[bk]min/km[bk]42:[bk]-[bk][bk]7:[bk]6:00[bk]min/km
3.
计算各个接力队的平均速度。输入的第一个数N意思是比赛的节数,第二个数D 为赛道的距离,单位是千米。第二行第一个数是队伍编号,这个没有什么意义,照着输出就行了,后面是一个以h:mm:ss格式表示的时间,以空格分隔,意为这个队伍完成这一小节比赛所消耗的时间,把所有的时间加起来就是这个队跑完全程(也就是上面输入的D)所用的总时间。对于每一组输入数据,输出这个队伍的平均速度,单位是min/km(**参考异常网)
4.
1、输入编号的候用%3d,否则前面的空格就会把输入搞乱了
2、把h:mm:ss的时间当做字符串输入,放在一个char数组中,用 strtok把里面的数字分离
3、把单位换算成 m:ss,min/km,即跑一千米用多少时间
4、计算结果的过程中注意要四舍五入,不能全部用整形
5、输出结果时,注意当秒数只有1位数的时候要在前面补0(不能出现4:8这种格式)
5.
#include <cstdio>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<math.h>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
//freopen("r.txt", "r", stdin);
int n,t,h,m,s,i,sum;
char arr[100];
double d;
cin>>n>>d;
while(~scanf("%d",&t))
{
int work=sum=0;
for(i=0;i<n;i++)
{
if(scanf("%d:%d:%d",&h,&m,&s)==3)
{
sum+=h*3600+m*60+s;
}
else
{
gets(arr);
work=1;
break;
}
}
if(work)
{
cout<<setw(3)<<t<<": -"<<endl;
}
else
{
sum=sum/d+0.5;
cout<<setw(3)<<t<<": "<<sum/60<<":";
if((sum%60)<10)
cout<<0;
cout<<sum%60<<" min/km"<<endl;
}
}
}
- acm 1007 接力问题
- 接力
- 幸福接力幸福接力
- 青云桥电站调速器接力器打不开问题处理
- 幸福接力
- 古诗接力
- 古诗接力
- 古诗接力
- 古诗接力
- 奶牛接力
- 传球接力
- 传球接力
- 传球接力
- 测试接力
- 接力break
- java线程接力演示
- 古诗接力(2-后半部)
- 人生杯具接力
- MFC-内存映射实现数据共享
- iOS开发之 [NSNull length]:unrecognized selector sent to instance
- 3.1趣味整数之亲密数
- 硬件电路设计流程及步骤
- 开启Mysql的慢查询日志
- acm 1007 接力问题
- [转] iOS中文版资源库,非常全
- 枚举和#define宏之间的区别
- 【设计模式C++】工厂模式
- Java集合框架
- 寻找数组中第k大的数
- 简单快捷地测试 JPush API
- [BZOJ3876][Ahoi2014]支线剧情
- warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545)