adajahpickens6870 adajahpickens6870
  • 11-05-2022
  • Computers and Technology
contestada

Write a function solution that given an array a of n integers (between -100 and 100), returns the sign (-1,0,1) of product of all the numbers in the array multiplied

Respuesta :

YulTheNinja YulTheNinja
  • 17-05-2022

left[0]=a[0];

for(int i=1;i<=n-1;i++)

   left[i]=(left[i-1]*a[i])%M;

right[n-1]=a[n-1];

for(int i=n-2;i>=0;i--)

   right[i]=(right[i-1]*a[i])%M;

for query q

   if(q==0)

       return right[1]%M;

   if(q==n-1)

       return left[n-2]%M;

   return (left[q-1]*right[q+1])%M;

Answer Link

Otras preguntas

Lily has two times as much money invested in 8% stocks as she has in bonds paying 6%. How much she has invested in stocks​ if her annual income from stocks and
Given: JK tangent, KH=16, HE=12 Find: JK.
WHAT IS THE FORMULA FOR QUICK LIME
Why did views on euthanasia shift towards acceptance during the 16th and 17th centuries? Culture of Life: Select the best answer from the choices provided. A
The [H3O+] of a solution is 2.5 x10-7. What is the pOH of the solution?
f(x) = 2x2 − 30, find f(4).
Congress passed a law imposing penalties for displaying indecent material online where children could see it. If the u.S. Supreme court subsequently rules that
can someone help me?!!!!!
If Logx (1 / 8) = - 3 / 2, then x is equal to A. - 4 B. 4 C. 1 / 4 D. 10
Find the value of X such that the data set has the given mean. 99, 123, 105, 114, 107, X; mean 108