只会做二次的,有哪位大佬能教一下二次以上的?
#include<bits/stdc++.h>
using namespace std;
const int N=300000;
int n,m;
int e[N],a,b,c,x,x1,x2;
int main(){
cin>>n>>m;
if(n==1){
cin>>a>>b;
x=-a/b;
if(x>=1&&x%1==0) cout<<1<<endl<<x;
else cout<<0;
return 0;
}
if(n=2){
cin>>c>>b>>a;
int zoo=b*b-4*a*c;
if(zoo<0) cout<<0;
else{
x1=(-b+sqrt(zoo))/(2*a);
x2=(-b-sqrt(zoo))/(2*a);
if(x1>=1&&x2>=1&&x1%1==0&&x2%1==0&&x1<=m&&x1!=x2) cout<<2<<endl<<x2<<endl<<x1;
else if((x1>=1&&x2<1&&x1%1==0&&x1<=m)||(x1==x2&&x1>=1&&x1<=m&&x1%1==0)) cout<<1<<endl<<x1;
else cout<<0;
return 0;
}
}
return 0;
}