Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void Divizeaza(int s, int d, int &m)
  6. {
  7. m=(s+d)/2;
  8. }
  9.  
  10. int f(int a, int b, int c, int x)
  11. {
  12. return a*x*x+b*x+c;
  13. }
  14.  
  15. void Combina(int x, int y, int &z)
  16. {
  17. z=x+y;
  18. }
  19.  
  20. void Dei(int a, int b, int c,int v[], int s, int d, int &z)
  21. {
  22. int m,x1=0,x2=0;
  23. if(s<d)
  24. {
  25. Divizeaza(s,d,m);
  26. Dei(a,b,c,v,s,m,x1);
  27. Dei(a,b,c,v,m+1,d,x2);
  28. Combina(x1,x2,z);
  29. }
  30. else
  31. if(f(a,b,c,v[s])==0)
  32. z=v[s];
  33. }
  34.  
  35. int main()
  36. {
  37. int v[100], n,z;
  38. int a,b,c;
  39. cin>>a>>b>>c;
  40. cin>>n;
  41. for(int i=0; i<n; i++)
  42. cin>>v[i];
  43. Dei(a,b,c,v,0,n-1,z);
  44. cout<<z;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement