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
The solid cylinders AB and BC are bonded together at B and are attached to fixed supports at A and C. The modulus of rigidity is
romanna [79]

Answer:

a) 0.697*10³ lb.in

b) 6.352 ksi

Explanation:

a)

For cylinder AB:

Let Length of AB = 12 in

c=\frac{1}{2}d=\frac{1}{2} *1.1=0.55in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}0.55^4=0.1437\ in^4\\

\phi_B=\frac{T_{AB}L}{GJ}=\frac{T_{AB}*12}{3.3*10^6*0.1437}  =2.53*10^{-5}T_{AB}

For cylinder BC:

Let Length of BC = 18 in

c=\frac{1}{2}d=\frac{1}{2} *2.2=1.1in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}1.1^4=2.2998\ in^4\\

\phi_B=\frac{T_{BC}L}{GJ}=\frac{T_{BC}*18}{5.9*10^6*2.2998}  =1.3266*10^{-6}T_{BC}

2.53*10^{-5}T_{AB}=1.3266*10^{-6}T_{BC}\\T_{BC}=19.0717T_{AB}

T_{AB}+T_{BC}-T=0\\T_{AB}+T_{BC}=T\\T_{AB}+T_{BC}=14*10^3\ lb.in\\but\ T_{BC}=19.0717T_{AB}\\T_{AB}+19.0717T_{AB}=14*10^3\\20.0717T_{AB}=14*10^3\\T_{AB}=0.697*10^3\ lb.in\\T_{BC}=13.302*10^3\ lb.in

b) Maximum shear stress in BC

\tau_{BC}=\frac{T_{BC}}{J}c=13.302*10^3*1.1/2.2998=6.352\ ksi

Maximum shear stress in AB

\tau_{AB}=\frac{T_{AB}}{J}c=0.697*10^3*0.55/0.1437=2.667\ ksi

8 0
3 years ago
25 points and brainliest is it A, B, C, D
Bogdan [553]

Answer:

SIR IT IS D HOPE THIS HELPS (☞゚ヮ゚)☞☜(゚ヮ゚☜)

Explanation:

4 0
3 years ago
Read 2 more answers
It is said that Archimedes discovered his principle during a bath while thinking about how he could determine if KingHiero‘s cro
Rudiy27

Answer:

the crown is false densty= 12556kg/m^3[/tex]

Explanation:

Hello! The first step to solve this problem is to find the mass of the crown, this is found using the weight of the crown in the air by means of the equation for the weight.

W=mg

W=weight(N)=31.4N

M=Mass

g=gravity=9.81m/S^2

solving for M

m=W/g

m=\frac{31.4N}{9.81m/S^2}=3.2kg

The second step is find the volume of crown  remembering that when an object is weighed in the water the result is the subtraction between the weight of the object and the buoyant force of the water which is the product of the volume of the crown by gravity by density of water

F=mg-\alpha  V g

Where

F=weight in water=28.9N

m=mass of crown=3.2kg

g=gravity=9.81m/S^2

α=density of water=1000kg/m^3

V= crown´s volume

solving for V

V=\frac{mg-F }{g \alpha } =\frac{(3.2)(9.81)-28.9}{9.81(1000)} =0.000254m^3

finally, we remember that the density is equal to the index between mass and volume

\alpha =\frac{m}{v} =\frac{3.2}{0.000254} =12556kg/m^3

To determine the density of the crown without using the weight in the water and with a bucket we can use the following steps.

1.weigh the crown in the air and find the mass

2. put water in a cylindrical bucket and measure its height with a ruler.

3. Put the crown in the bucket and measure the new water level with a ruler.

4. Subtract the heights, and find the volume of a cylinder knowing the difference in heights and the diameter of the bucket, in order to determine the volume of the crown.

5. find density by dividing mass by volume

7 0
3 years ago
The greater the force applied to an object, the _____ the change in speed or direction of the object.
storchak [24]

Answer:

b

Explanation:

8 0
3 years ago
To find the reactance XLXLX_L of an inductor, imagine that a current I(t)=I0sin(ωt)I(t)=I0sin⁡(ωt) , is flowing through the indu
Sophie [7]

Answer:

V(t) = XLI₀sin(π/2 - ωt)

Explanation:

According to Maxwell's equation which is expressed as;

V(t) = dФ/dt ........(1)

Magnetic flux Ф can also be expressed as;

Ф = LI(t)

Where

L = inductance of the inductor

I = current in Ampere

We can therefore Express Maxwell equation as:

V(t) = dLI(t)/dt ....... (2)

Since the inductance is constant then voltage remains

V(t) = LdI(t)/dt

In an AC circuit, the current is time varying and it is given in the form of

I(t) = I₀sin(ωt)

Substitutes the current I(t) into equation (2)

Then the voltage across inductor will be expressed as

V(t) = Ld(I₀sin(ωt))/dt

V(t) = LI₀ωcos(ωt)

Where cos(ωt) = sin(π/2 - ωt)

Then

V(t) = ωLI₀sin(π/2 - ωt) .....(3)

Because the voltage and current are out of phase with the phase difference of π/2 or 90°

The inductive reactance XL = ωL

Substitute ωL for XL in equation (3)

Therefore, the voltage across inductor is can be expressed as;

V(t) = XLI₀sin(π/2 - ωt)

3 0
3 years ago
Other questions:
  • Given the following data, plot the stress-strain curves for the two unknown materials on the same set of stress-strain axes. Den
    9·1 answer
  • PLZ HURRY IM ON A TIMER
    6·1 answer
  • A heat pump receives heat from a lake that has an average wintertime temperature of 6o C and supplies heat into a house having a
    12·1 answer
  • Project 8:The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exe
    5·1 answer
  • What structure was created to help prevent shipwrecks?
    9·1 answer
  • What is the name of the part that supports the headlight assembly?
    15·1 answer
  • How many times has the ITU-R revised the CCIR 601 international standard? A. four B. five C. six D. seven
    8·1 answer
  • Airplanes are the only way that people can take flight.<br> A. True<br> B. False
    14·2 answers
  • You have a 12 volt power source running through a circuit that has 3kΩ of resistance, how many amps (in mA) can flow through the
    15·1 answer
  • Who made the frist ever car
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!