前面的导语有点吓人,但简言之只是单位换算题目 ,并没有什么难度。需要注意 的是 , 除了 各个数据具体的单位外,还有就是时间也是浮点数,否则会 TLE。
Run Time: 0sec
Run Memory: 304KB
Code length: 358Bytes
SubmitTime: 2012-01-31 17:14:35 Code
// Problem#: 1051
// Submission#: 1203282
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <cstdio>
using namespace std;
int main()
{
double r, time, dist;
int n;
for ( int i = 1; true; i++ ) {
scanf( "%lf%d%lf", &r, &n, &time );
if ( n == 0 )
break;
dist = 3.1415927 * r * n / 12 / 5280;
printf( "Trip #%d: %.2lf %.2lf\n", i, dist , dist / time * 60 * 60 );
}
return 0;
}
本文介绍了一个简单的单位换算程序,该程序能够将输入的距离和时间从特定单位转换为英里和小时。通过使用浮点数确保计算精度,避免了时间上的超时错误。代码示例展示了如何读取输入并进行必要的计算。
156

被折叠的 条评论
为什么被折叠?



