1043: Fixed Point

时间限制: 5 Sec  内存限制: 128 MB
提交: 26  解决: 5
[提交][状态][讨论版]

题目描述

In mathematics, a fixed point (sometimes shortened to fixpoint, also known as an invariant point) of a function is a point that is mapped to itself by the function. That is to say, x is a fixed point of the function f if and only if f(x) = x. For example, if f is defined on the real numbers by f(x)=x*x-3*x+4.,then 2 is a fixed point of f, because f(2) = 2.

Not all functions have fixed points: for example, if f is a function defined on the real numbers as f(x) = x + 1, then it has no fixed points, since x is never equal to x + 1 for any real number. In graphical terms, a fixed point means the point (x, f(x)) is on the line y = x, or in other words the graph of f has a point in common with that line. The example f(x) = x + 1 is a case where the graph and the line are a pair of parallel lines.

------ http://en.wikipedia.org/wiki/Fixed_point_%28mathematics%29

Our problem is,for a defined on real number function:

f(x)=a*x*x*x+b*x*x+c*x+d,how many different fixed points does it have?

输入

There are multiple test cases.For each test cases, there are four integers a, b, c and d in a single line.
You can assume that -213<=a<=213, -213<=b<=213, -213<=c<=213, -213<=d<=213,and the number of the result is countable.

输出

For each test case, output the answer in a single line.

样例输入

3 111 793 -3456
5 -135 811 0
-1 9 10 -81

样例输出

3
3
3


#include<iostream>
#include<math.h>
using namespace std;
int main(){freopen("in.txt", "r", stdin);double a3, b3, c3, d3;double a2, b2, c2;while (cin >> a3 >> b3 >> c3 >> d3){c3--;a2 = 3 * a3; b2 = 2 * b3; c2 = c3;if (a3 == 0){if (b3 == 0)//一次方程{if (c3 == 0){//只剩常数cout << 0 << endl;}else cout << 1 << endl;}else{//二次方程double delta = c3*c3 - 4 * b3*d3;if (delta == 0)cout << 1 << endl;else if (delta>0)cout << 2 << endl;else cout << 0 << endl;}}else{//三次方程double delta = b2*b2 - 4 * a2*c2;if (delta <= 0)//单调递增cout << 1 << endl;else{double x1 = (-b2 - sqrt(delta)) / (2 * a2);double x2 = (-b2 + sqrt(delta)) / (2 * a2);double y1 = a3*x1*x1*x1 + b3*x1*x1 + c3*x1 + d3;double y2 = a3*x2*x2*x2 + b3*x2*x2 + c3*x2 + d3;double see = y1*y2;if (see == 0)cout << 2 << endl;else if (see > 0)cout << 1 << endl;else cout << 3 << endl;}}}return 0;
}

转载于:https://www.cnblogs.com/weiyinfu/p/5013901.html

东大OJ-一元三次方程解的个数相关推荐

  1. 解一元二次方程 matlab,如何用Matlab求一元二次方程式解的个数以及解

    我们学习数学经常会遇到一元二次方程式,那么如何用Matlab软件求一元二次方程式解的个数以及各个解的值呢?下面小编给大家分享一下. 工具/材料 Matlab 首先打开Matlab软件,点击左上角的Ne ...

  2. 盛金公式解一元三次方程_一元三次方程解法(卡尔丹公式法盛金公式法)

    卡尔丹公式法 特殊型一元三次方程 X^3+pX+q=0 (p.q∈R) 判别式Δ=(q/2)2+(p/3)3 卡尔丹公式 X1=(Y1)(1/3)+(Y2)(1/3) X2= (Y1)(1/3)ω+( ...

  3. 解一元三次方程方程问题细节探讨

    解一元三次方程 虽然我是一个新手,按"规矩"应该要经常在博客里面把自己的错误都写出来做个总结,但是我比较保守,总是觉得博客是一个社交平台,一些相对不太成熟的东西还是写个word文档 ...

  4. 解一元三次方程noip2001

    题目描述 有形如:ax^3+bx^2+cx^1+dx^0=0ax3+bx2+cx1+dx0=0 这样的一个一元三次方程.给出该方程中各项的系数(a,b,c,da,b,c,d均为实数),并约定该方程存在 ...

  5. 盛金公式解一元三次方程_【国际数学竞赛】高次方程求根

    对于一元二次方程 ,我们由求根公式可得: . 对于一元三次方程 ,我们有 卡尔丹公式法和盛金公式法.不过公式比较冗长.不易计算,但我们还是有方法计算的,那么如果是一元四次.一元五次甚至更高呢? 遇到高 ...

  6. 问题三十七:C++怎么解一元四次方程?(2)——怎么解一元三次方程

    37.2 怎么解一元三次方程? 用"盛金公式"求解: ----------------------------------------------main.cpp -------- ...

  7. 牛顿迭代法解一元三次方程

    题目描述 有形如:ax^3+bx^2+cx^1+dx^0=0ax3+bx2+cx1+dx0=0 这样的一个一元三次方程.给出该方程中各项的系数(a,b,c,da,b,c,d均为实数),并约定该方程存在 ...

  8. 求解一元三次方程的一个实数解

    求解已知一元三次方程的一个实数解 上机内容:C++ 上机目的: 编程序求解方程2x3-5*x2+3x-6=0的1个实数根,要求精确到0.00001 已知f(x)=2x3-5*x2+3x-6 在> ...

  9. 盛金公式解一元三次方程_盛金公式解一元三次方程

    Module Shengjin_mod Implicit None contains Function Cubic_equation(Co) Result (X) !盛金公式求解一元三次方程 !默认浮 ...

最新文章

  1. 服务器 主动 推送 客户端浏览器 消息***
  2. python自动化办公兼职-python自动化办公?学这些就够用了
  3. 解决IE下jquery ajax无法获得最新数据的问题(IE缓存)
  4. LeetCode 421. 数组中两个数的最大异或值
  5. php代码提示助手,laravel自动补全助手ide-helper安置及配置
  6. [HTA] - HTML应用程序
  7. C#设计模式学习(类型对象模式)
  8. github 远程仓库操作
  9. 重构Webpack系列之一 ---- 概念篇
  10. 【2021】【论文笔记】太赫兹量子阱光电探测器——
  11. D. Binary Spiders(dpTrie)
  12. 智能家居无创新,不智能
  13. 新品“鸿鹄”获2020世界VR产业大会创新金奖!
  14. czl蒻蒟的OI之路9
  15. php显示网络图片,php中显示图片的方法
  16. 每日C语言代码(The sixth day)——选择排序法
  17. xzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  18. java一个等号_java中等号的涵义
  19. 请求和寻求帮助|Outreachy
  20. java实现家庭财务管理_基于jsp的家庭财务管理系统-JavaEE实现家庭财务管理系统 - java项目源码...

热门文章

  1. [Robot Framework] Jenkins上调用Rebot命令时执行报错不往下执行其他命令
  2. JavaScript 中,定义函数时用 var foo = function () {} 和 function foo() 有什么区别?
  3. loadrunner录制脚本参数化之间的关联设置
  4. 表达式求值(NOIP2013 普及组第二题)
  5. 单行文本和多行文本溢出以省略号显示方法
  6. 微信读书App来了 小伙伴们快去占榜吧
  7. MC新手入门(十三)------ 添加游戏角色
  8. win32 api for .net
  9. WinForm 的dataGridView全选,反选
  10. B/S、C/S双客户类型系统研究