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

Read the passage below, looking for the following 10 mistakes…Rewrite the paragraph, making the necessary revisions so that the paragraph has correct grammar.
Please help it’s for Alex
The football team has a total of 25 jerseys. There are 10 ​medium-sized jerseys. What percent of the jerseys are​ medium-sized jerseys?
Pam walks 7/8 of a mile to school.Paul walks 5/6 of a mile to school.How much farther does Pam walk than Paul?
What is the product of the two integer values for $x$ for which $|x^2 - 16|$ is a prime number?
if i need to pay 154 dollars for something but get paid 10 dollars every week how many weeks would i have to wait
Brandon has a 55-gallon fish tank. He estimates he can drain the tank at an average rate of 11 gallons per minute. In a linear model of this situation, x repre
fa line has the equation 2y=-3x+1. Find an equation of a line parallel to this line that has a y-intercept of -2.
What is 40% of 85? (with an explanation)
How does kafka set the tone for chapter 2? Explain the significance of his choices. ( The Metamorphosis)