1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zhenek [66]
3 years ago
14

/* Function findBestVacation * duration: number of vacation days * prefs: prefs[k] indicates the rate specified for game k * pla

n: array with 366 positions with the sequence of games * to be played over the year. In other words, * plan[k] indicates the game planned for day k (1

Engineering
1 answer:
alexira [117]3 years ago
3 0

Answer:

This is the C++ code for the above problem:

#include<bits/stdc++.h>

using namespace std;

int computeFunLevel(int start, int duration, int prefs[], int ngames, int plan[]) {

if(start + duration > 365) { //this is to check wether duration is more than total no. of vaccation days

return -1;

}

int funLevel = 0;

for(int i=start; i<start+duration; i++) { //this loop runs from starting point till

//start + duration to sum all the funlevel in plan.

funLevel = funLevel + prefs[plan[i]];

}

return funLevel;

}

int findBestVacation(int duration, int prefs[], int ngames, int plan[]) {

int max = 0, index = 0, sum = 0 ;

for(int i=1; i<11; i++){ //this loop is to run through whole plan arry

sum = 0; //sum is initialized with zero for every call in plan ,

//in this case loop should run to 366,but for example it is 11

//as my size of plan array is 11

for(int j=0; j<duration; j++) { // this loop is for that index to index+duration to calc

//fun from that index

sum = sum + prefs[plan[i]];

}

if(sum>max) { //this is to check max funlevel and update the index from which max fun can be achieved

max = sum;

index = i;

}

}

return index;

}

int main() {

int ngames = 5;

int prefs[] = { 1,2,0,5,2 };

int plan[] = { 0,2,0,3,3,4,0,1,2,3,3 };

int start = 1;

int duration = 4;

cout << computeFunLevel(start, duration, prefs, ngames, plan) << endl;

cout << computeFunLevel(start, 555, prefs, ngames, plan) << endl;

cout << findBestVacation(4, prefs, ngames, plan) << endl;

}

The screen of the program is given below.

You might be interested in
Brainly and points if you want
Tju [1.3M]

Answer:

thank you

Explanation:

have a nice day

8 0
2 years ago
Read 2 more answers
When you first start a car after it has been sitting for more than an hour, it pollutes up to ......times more than when the eng
lesya [120]
20 time more then when it’s warm
6 0
3 years ago
Read 2 more answers
Velocity components in an incompressible flow are: v = 3xy + x^2 y: w = 0. Determine the velocity component in the x-direction.
cupoosta [38]

Answer:

Velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

Explanation:

   v=3xy+x^{2}y

We know that for incompressible flow

   \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}=0

\frac{\partial v}{\partial y}=3x+x^{2}

So   \frac{\partial u}{\partial x}+3x+x^{2}=0

\frac{\partial u}{\partial x}= -3x-x^{2}

By integrate with respect to x,we will find

u=-\frac{3}{2}x^2-\frac{1}{3}x^3+C

So the velocity component in x-direction u=-\frac{3}{2}x^2-\frac{1}{3}x^3.

3 0
3 years ago
Jump starting a car requires _____.
maria [59]

Answer:

D

Explanation:  you need a jump cable to hook on a power source because the jump cable has two color cables to hook up to the power source. the two jump cables have two colors to tell you which one is positive and negative. The red one is the positive and the black on is the negative one.

5 0
3 years ago
Read 2 more answers
A 50 Hz, four pole turbo-generator rated 100 MVA, 11 kV has an inertia constant of 8.0 MJ/MVA. (a) Find the stored energy in the
raketka [301]

Given Information:

Frequency = f = 60 Hz

Complex rated power = G = 100 MVA

Intertia constant = H = 8 MJ/MVA

Mechanical power = Pmech = 80 MW

Electrical power = Pelec = 50 MW

Number of poles = P = 4

No. of cycles = 10

Required Information:

(a) stored energy = ?

(b) rotor acceleration = ?

(c) change in torque angle = ?

(c) rotor speed = ?

Answer:

(a) stored energy = 800 Mj

(b) rotor acceleration = 337.46 elec deg/s²

(c) change in torque angle (in elec deg) = 6.75 elec deg

(c) change in torque angle (in rmp/s) = 28.12 rpm/s

(c) rotor speed = 1505.62 rpm

Explanation:

(a) Find the stored energy in the rotor at synchronous speed.

The stored energy is given by

E = G \times H

Where G represents complex rated power and H is the inertia constant of turbo-generator.

E = 100 \times 8 \\\\E = 800 \: MJ

(b) If the mechanical input is suddenly raised to 80 MW for an electrical load of 50 MW, find rotor acceleration, neglecting mechanical and electrical losses.

The rotor acceleration is given by

$ P_a = P_{mech} - P_{elec} = M \frac{d^2 \delta}{dt^2}  $

Where M is given by

$ M = \frac{E}{180 \times f} $

$ M = \frac{800}{180 \times 50} $

M = 0.0889 \: MJ \cdot s/ elec \: \: deg

So, the rotor acceleration is

$ P_a = 80 - 50 = 0.0889 \frac{d^2 \delta}{dt^2}  $

$  30 = 0.0889 \frac{d^2 \delta}{dt^2}  $

$   \frac{d^2 \delta}{dt^2} = \frac{30}{0.0889}  $

$   \frac{d^2 \delta}{dt^2} = 337.46 \:\: elec \: deg/s^2 $

(c) If the acceleration calculated in part(b) is maintained for 10 cycles, find the change in torque angle and rotor speed in revolutions per minute at the end of this period.

The change in torque angle is given by

$ \Delta  \delta = \frac{1}{2} \cdot \frac{d^2 \delta}{dt^2}\cdot (t)^2 $

Where t is given by

1 \: cycle = 1/f = 1/50 \\\\10 \: cycles = 10/50 = 0.2  \\\\t = 0.2 \: sec

So,

$ \Delta  \delta = \frac{1}{2} \cdot 337.46 \cdot (0.2)^2 $

$ \Delta  \delta = 6.75 \: elec \: deg

The change in torque in rpm/s is given by

$ \Delta  \delta = \frac{337.46 \cdot 60}{2 \cdot 360\circ  }   $

$ \Delta  \delta =28.12 \: \: rpm/s $

The rotor speed in revolutions per minute at the end of this period (10 cycles) is given by

$ Rotor \: speed = \frac{120 \cdot f}{P}  + (\Delta  \delta)\cdot t  $

Where P is the number of poles of the turbo-generator.

$ Rotor \: speed = \frac{120 \cdot 50}{4}  + (28.12)\cdot 0.2  $

$ Rotor \: speed = 1500  + 5.62  $

$ Rotor \: speed = 1505.62 \:\: rpm

4 0
3 years ago
Other questions:
  • Consider the following program:
    15·1 answer
  • Calculate the density of the FCC nickel lattice with an interstitial hydrogen in the centered position of the unit cell. You may
    10·1 answer
  • Please help me in this assignment.
    13·1 answer
  • An air-conditioning system operating on the reversed Carnot cycle is required to transfer heat from a house at a rate of 755 kJ/
    7·1 answer
  • Water vapor at 5 bar, 320°C enters a turbine operating at steady state with a volumetric flow rate of 0.65 m3/s and expands adia
    6·1 answer
  • Given two alphabet strings str1 and str2. You can change the characters in str1 to any alphabet characters in order to transform
    8·1 answer
  • QUESTION:
    13·1 answer
  • Di hola por 10 puntos
    8·1 answer
  • Which Two moon phases are directly opposite each other?
    9·2 answers
  • 15- Vipsana's Gyros House sells gyros. The cost of ingredients (pita, meat, spices, etc.) to make a gyro is $2.00. Vipsana pays
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!