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

Breakfast-skippers commonly struggle more with ______________ than do breakfast eaters. a. muscle exhaustion b. body fatness c. iron deficiency d. hypertens
What happens to the water after it reaches the leaves of a plant?
To be considered a living thing an organism must be able to a. swim. b. reproduce. c. digest food. d. talk.
what is 456,420 divided by 8.75 million
A benefit of using good human relations is that you will
Who first introduced Buddhism and Chinese writing to Japan?
Sociologists recognize two basic types of stratification. a. true b. false
In an ecosystem, available energy___________________ at each successive trophic level. a. diminishes c. stays the same b. increases d. none of the above
how to find the reciprocal of a mixed fraction
Two similar triangles are shown below: Two triangles are shown. The sides of the triangle on the left are marked 6, 8, 4. The sides of the triangle on the right