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

The Industrial Revolution began in Great Britain partly because economists there:
why various body parts are more or less sensitive to touch?
pls help this is due in like 15 minutes
A side of the triangle below has been extended to form an exterior angle of 128°. Find the value of x.
What is the ones digit in the number 2²⁰⁵³?​
Find the slope of the line that goes through the points (5,9) and (3,11).
Review the results of your first experiment from task 2, part B. When force is fixed, does an increase in mass increase or decrease acceleration? The equation f
Use the following scenario on the next three (3) questions. Function R is defined by R (n) = 40n, where n, is the number of campers. Question 3 1 pts Is 20 a p
Help Pleaseee!!!!!!!!!!!
There are 29 second graders at recess. Then, 27 third graders and 43 fourth graders join them at recess. How many students are at recess?