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

Why were the Germans so upset with the "War Guilt Clause"?
What is the area of a circle with circumference of 37.68? (Use 3.14 for p.)
Which was a chief goal of european colonial rule in africa?
Can someone help it is due tomorrow
What is the answer to this chemistry question
Describe the different types of seedless, non-vascular plants. In your description include the three different types, where you would find each type, and how ea
Without actually writing the formula, explain how to expand (x + 3)7 using the binomial theorem.
For the given quadratic equation convert into vertex form, find the vertex, and find the value for x = 6. Show your work. y = -2x2 + 2x +2
Read the scenario. An American journalist is being held in a foreign prison. The president is meeting with his administration to determine what to do. The pres
differences and similarities between Xinjiang Chechnya and Quebec