代數基本定理
n次方程式存在n個解(根)
故,只有在係數皆為0時,才可能有無限多組解
#include <iostream>
using namespace std;
int main()
{
long long int a, b, c, d , e, f, F[3];
bool root;
while(cin >> a >> b >> c >> d >> e >> f)
{
if(!a && !b && !c && !d && !e && !f)
{
cout << "Too many... = =\"" << endl;
continue;
}
root = false;
F[0] = F[1] = 0;
for(long long int x = -73; x<74; x++)
{
F[0] = F[1];
F[1] = a*x*x*x*x*x + b*x*x*x*x + c*x*x*x + d*x*x + e*x + f;
if ( (F[0] > 0 && F[1] < 0) || (F[0] < 0 && F[1] > 0) )
{
root = true;
cout << x-1 << " " << x << endl;
}
else if(F[1] == 0)
{
root = true;
cout << x << " " << x << endl;
}
}
if(root == false)
cout << "N0THING! >\\\\\\<" << endl;
}
}