2019.8.4 雷火笔试第五题 黑客行动(98%)
昨天碰到这个题惊了,游戏笔试题居然还考逆向,难道我投成安全岗了?...
具体的反汇编过程在昨天写的博客里,比较浅显,不懂汇编的也能看个大概,感兴趣的可以看看,https://blog.csdn.net/likewind1993/article/details/98473562
最后得到的F(x)是:
提交代码:
#include <stdio.h> #include <math.h> float f(float x) { float a = 40.371, b = 36.819, c = 0.378, d = 0.3855, e = 3.0521; return a*pow(x, 4) - b*pow(x, 3) + c * pow(x, 2) + d * x + e; } int main() { float x = 0; scanf("%f", &x); if (x <0.0 || x >=1.0) { printf("error\n"); return 0; } printf("%0.6f", f(x)); return 0; }
测试用例只过了98%, 最后想了想,应该是f(x)里的用float不够,应该用double(改成下面这种),可惜已经交卷,没法再试了。
double f(float x) { double a = 40.371, b = 36.819, c = 0.378, d = 0.3855, e = 3.0521; return a*pow(x, 4) - b*pow(x, 3) + c * pow(x, 2) + d * x + e; }