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

Selena walks from home to school each morning and back home each afternoon.altogether , she walks 2/3 mile each day . How far does Selena live from school?
The "permanent" wave that your local beauty parlor offers depends critically on rearrangements in the extensive disulfide bonds of keratin that give your hair i
Please help, anyone! I really need help! A scatter plot is shown: What type of association does the graph show between x and y? Linear positive association N
can someone please assist me in this spanish homework please ???
14 plums cost $2.00. What is the cost,to the nearest cent, of 50 plums?
What is the slope and y-intercept of the line represented by this equation? y = 9x - 2
A square dining room table has an area of 20 ft. Squared. What is the length of each side of the table to the nearest tenth?
Which type of clothing was a highlight of youth fashion after WWII?
What isn’t the exact value for Sin(1305) degrees ?
What is southern blot as a part of the gel electrophoresis process? And what does it tell you?