题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=6038
因为TopCoder SRM比赛使用的编译器进行了升级,所以进行了一次Test SRM,这次比赛不计rating. 题目是从SRM 200 -400间随机选择的。
这道题目就是解一个二元一次方程。
代码如下:
#include <iostream>
using namespace std;
class TemperatureScales
{
public:
double convert(int f1, int b1, int f2, int b2, int t);
};
double TemperatureScales::convert(int f1, int b1, int f2, int b2, int t)
{
double a, b;
a = ( (double)(f2 - b2) ) / (f1 - b1);
b = ( (double)(f1*b2 - f2*b1) ) / (f1 - b1);
return (double)(a * t + b);
}