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

Describe the ocean product you researched in the "investigation: ocean products" module. What did you learn about it's connection to the ocean?
WHAT IS ONE WAY IN WHICH AN ACTIVE LISTENER CAN COMFIRM UNDERSTANDING OF A MESSAGE
Is it possible for a system of linear equations to have exactly two solutions?
present simple negative respuesta
QUESTION DOWN BELOW PLEASE HELP!! ITS DUE SOON!
If you put a hot dog into piranha solution, what happens? it dissolves becomes electroplated with salt noithing - nonreactive produces carbon triethylium oxide
Repeated sickling causes fragile _ to have a shortened life span, resulting in _
why is 25 a compiste number
is 5 square root-2 square root rational?
Rashad is researching the Dakota Access Pipeline controversy. He comes across this news account. An article titled Biden Administration Side-Steps on D A P L th