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

What is the measure of
I need help with this plz help
What is the value of the expression? 84-24428 13 115 13.4 152 O
In addition to keeping the nobles and royal princes busy so that they would stay out of politics, what other reason could explain why Louis XIV invited them to
The mean of 20 items is 40 and the mean ofanother 30 items is 60. What is the mean ofde angles ofwhole set of items?​
Next Managing Files and Directories: Mastery Test 2 Select the correct answer from each drop-down menu. How will you identify a file type on your computer? that
What claim can you make about the relationship between kinetic energy and potential energy?
which two qualities are required for a martial art practitioner​
How democratic is low voter turnout?
7. The systematic application of managers' knowledge, logic, quantitativemeasurement and experimental verification expresses management as​