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

A sample of gas with an initial volume of 29.1 Lat a pressure of 719 mm Hg and a temperature of 306 K is compressed to a volume of 14.1 L and warmed to a temper
Is space colonization necessary? Explain why or why not, using evidence from the passage
The area of a parallelogram is 780sq cm if the length of one side is 26cm find the corresponding height. 20 points
Bir yönetim fonksiyonu olarak Halkla İlişkiler
Given the figure below find if fgh is an equalateral triangle then choose from the answer choices​
help me pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Draw the graph of f(x) square 2 Root of2 x- 4 +2
Can you please show all the steps with explanations.
Which number line represents the solutions to |–2x| = 4?(I want a clear explanation)
PART A: How does paragraph 22 contribute to the development of ideas in the text? A. It shows how unreasonable James Harvey was in his youth. B. It provides an