Answers
This is easy. Lets define the state of the locker as open or closed. At any given point in time we know that a locker will be in one of these two states. Lets say we denote open state by 1 and closed state by 0. so we have to print all the lockers with open state which is 1 at the end of the task.
We can do this in the following way.
Code :
#include <iostream>
using namespace std;
int main() {
//set all lockers state to closed
int lockers[101]={0};
for(int i = 1;i<=100;i++){
//we will start from ith locker for ith student
for(int j=i;j<=100;j=j+i){
//toggle the state of the lockers
lockers[j]=1-lockers[j];
}
}
for(int i =1;i<=100;i++){
if(lockers[i]==1){
cout<<i<<" ";
}
}
cout<<endl;
return 0;
}
OUTPUT :
1 4 9 16 25 36 49 64 81 100.
Similar Solved Questions
1 answer
During a particular transformation protocol, you used a stock of PGLO DNA with a concentration of...
During a particular transformation protocol, you used a stock of PGLO DNA with a concentration of 0.08 ug ul. You transformed 191 UL of competent E. coli with 100L of PGLO DNA. You added 191 UL of LB broth to the transformation before plating 100 uL of the culture to a plate labeled +POLO, LB, Amp, ...
1 answer
Help Save & Exit 5 Check my Required information The following information applies to the questions...
Help Save & Exit 5 Check my Required information The following information applies to the questions displayed below.) Part 1 of 3 The following events occur for The Underwood Corporation during 2021 and 2022, its first two years of operations. points (8 02:19:10 June 12, 2021 Provide services to...
1 answer
A horse and rider are racing to the right with a speed of 21when they pass...
A horse and rider are racing to the right with a speed of 21when they pass the finish line and begin slowing down. The horse slows for 52 m with constant acceleration before it stops. What was the acceleration of the horse as it came to a stop? Answer using a coordinate system where rightward is pos...
1 answer
19. Consider the following situation. Two wavepulses are moving toward each other on a spring. The...
19. Consider the following situation. Two wavepulses are moving toward each other on a spring. The wavepulses are shown at t-0 sec. The left pulse moves at a speed of 100 cm/s. Each block represents 1 cm to see a What is the speed of the right wavepulse? Explain. 20. Sketch the shape of the spring a...
1 answer
I need a 8-10 page essay about essay Volunteering and Risk Management
I need a 8-10 page essay about essay Volunteering and Risk Management...
1 answer
6. 003 points 1 Previous Answers SerPOPS 7.P.025. W Ak Your Teacher A toy cannon uses...
6. 003 points 1 Previous Answers SerPOPS 7.P.025. W Ak Your Teacher A toy cannon uses a spring to project a 5.39-soft rubber ball. The spring is originally compressed by 4.99 cm and has a force constant of 7.95 Nm. When the cannon is fired, the ball moves 102 cm through the horizontal barrel of the ...
1 answer
D. True or False: *c+dr) (.***dy) = M2. e. True or False: C dr -)" dy...
d. True or False: *c+dr) (.***dy) = M2. e. True or False: C dr -)" dy wy) - [*]****dardy. f. Use polar coordinate to evaluate $*$***edrdy g. True or False dar = V. h. Compute the integral Historical Perspective: This is the integral of your "bell- shaped" curve. Actually it does not look...
1 answer
Excel Online Structured Activity: Interval Estimation for the Population Mean with σ Known AARP r...
Excel Online Structured Activity: Interval Estimation for the Population Mean with σ Known AARP reported on a study conducted to learn how long it takes individuals to prepare their federal income tax return (AARP Bulletin, April 2008). The data contained in the Microsoft Excel Online file bel...
1 answer
It is better if both can be solved. Design a power generation system by choosing one...
It is better if both can be solved. Design a power generation system by choosing one of the options given below. 1. Geothermal sourced power plant Define the geothermal power plant type (Total Flow/Flash/binary) Define turbine isentropic efficiency Show all the processes on a T-s diagram Calculate h...
1 answer
For each pair of substances, anticipate which one has a higher boiling point. HF has a...
For each pair of substances, anticipate which one has a higher boiling point. HF has a .... than HCl . CCl4(l) has a .... than CH3Cl(g) . CH3OCH3 has a .... than CH3CH2CH3 . CH3OCH3 has a .... than CH3NHCH3 . H2S has a .... than H2Se...
1 answer
Please help answer these QUESTION 4 Which managerial function involves setting goals, establishing a strategy to...
please help answer these QUESTION 4 Which managerial function involves setting goals, establishing a strategy to pursue those goals, and forecasting future threats and opporturites hat might influence the company's needs and strategies? O A planning С.leading ○D.cortrolig QUESTI...
1 answer
Please provide the expected return and the standard deviation to the table above. Question 13 Susan...
Please provide the expected return and the standard deviation to the table above. Question 13 Susan is considering investing in a company's stock and is aware that the return on that investment is particularly sensitive to how the economy is performing. Her analysis suggests that four states of ...
1 answer
Determine whether the distribution is a discrete probability distribution. Oo 0.30 2 3 4 -0.10 0.30...
Determine whether the distribution is a discrete probability distribution. Oo 0.30 2 3 4 -0.10 0.30 0.25 Is the distribution a discrete probability distribution? Why? Choose the correct answer below. O A. Yes, because the distribution is symmetric. OB. No, because some of the probabilities have valu...
1 answer
Nuparc Company provided services on account for a customer that amounted to $1,100. How would this...
Nuparc Company provided services on account for a customer that amounted to $1,100. How would this transaction be shown in the accounting equation? (Use only the necessary input cells.) Shareholders' Equity Assets Liabilities Contributed Capital Retained Earnings $ Account Accounts Account Accou...
1 answer
11 What is the impact on cash flow from operations in the current year based on...
11 What is the impact on cash flow from operations in the current year based on the change in operating assets and liabilities listed below? 2 Balance sheets Prior Year Current Year 4 5 Accounts receivable 6 Inventories 7 Accounts payable 1,725 1,535 1,325 1,825 1,785 1,475 -200 -150 200 12 What'...
1 answer
Question 5 We invest $ 100 in a bank that offers 4% nominal interest rate compounded...
Question 5 We invest $ 100 in a bank that offers 4% nominal interest rate compounded monthly. How long (how many years) will it take to earn $20 in interest?...