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

unlike psychodynamic therapists, humanistic therapists tend to focus on the ________ more than the ________.
What is one way in which China or Taiwan has grown economically, and what is one challenge China or Taiwan faces today?
Explain the similarities and difference between narrative poetry and lyric poetry.
Which expression has a value of 20? 9 + 21 ÷ (3 + 2 × 5) (9 + 21) ÷ 3 + 2 × 5 9 + (21 ÷ 3 + 2) × 5 9 + 21 ÷ (3 + 2) × 5
the ________ is part of the processor that manages the movement of data through the cpu.
what is the formula of kinetics?​
two supplementary angles have measures 6x° and 12x°. find each angle measure’
A rectangular prism has a length of 414 in, a width of 3 in, and a height of 114 in. what is the volume of the prism?
I need help understanding and translating this conversation. I have correctly answered most of the words, but I do not understand which other words fit in the c
Why would people decide to participate in team sports? What are the aspects of team sports that attract people?