UVa 10509 - R U Kidding Mr. Feynman?
来源:互联网 发布:软件开发精品课程 编辑:程序博客网 时间:2024/05/21 08:02
题目:函数的渐进解,利用式子f(x+dx)= f(x)+ f`(x)dx,求x+dx;
其中x为f(x)处理求解的整数解,反推dx = (f(x+dx)- f(x))/f`(x)。
分析:分治。这里f(x) = x^3,直接利用二分求解x的最近整数解,然后接dx = (n-a^3)/(3a^2);
整理求解x+dx即可。
说明:这里不能使用库函数,否则精度会出现问题。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;int bs(double x){int l = 1,r = 100,mid;while (l < r) {mid = (r+l+1)/2;if (x >= 1.0*mid*mid*mid)l = mid;else r = mid-1;}return r;}int main(){double x,y,dx;while (~scanf("%lf",&x) && x) {y = bs(x);dx = (x-y*y*y)/3.0/y/y;printf("%.4lf\n",y + dx);} return 0;}
0 0
- UVa 10509 - R U Kidding Mr. Feynman?
- UVa 12149 - Feynman
- Feynman
- UVa 10323 - Factorial! You Must be Kidding!!!
- T.U.R.F
- UVa 10490 - Mr. Azad and his Son!!!!!
- UVA 11440(p338)----Help Mr.Tomisu
- MR
- Feynman(数学)
- live archive 4215 - Feynman
- SPOJ 3410 Feynman
- “J.U.C”:Condition (r)
- “J.U.C”:Semaphore (r)
- “J.U.C”:CyclicBarrier (r)
- “J.U.C”:CountDownlatch (r)
- “J.U.C”:Phaser (r)
- Python!Are you kidding me?
- JUST KIDDING 0001 指鹿为马排序
- UVA-1030-Image Is Everything
- Swing JList使用
- 利用matlab计算Pearson和Spearman相关系数
- Remove Duplicates from Sorted Array
- 西安之行-兵马俑-大雁塔-古城墙
- UVa 10509 - R U Kidding Mr. Feynman?
- Zen of Dev
- android判断网络状态等操作
- LeetCode Reverse Nodes in k-Group
- 从产品经理的角度看《我是歌手》
- Codeforces 513C Second price auction (bruteforce)
- CodeChef STFM - Chef and Strange Formula (康托展开)
- Go语言开发环境配置
- 主流MVC框架的设计模式及遵守的软件设计原则