New course! Every coder should learn Generative AI!
Try a free lesson+ 1
1. Try to use modulus operator to the total passengers and max capacity to get the number of passenger in LAST BUS.
2. Then subtract it by 50 to get the FREE or REMAINING SEATS.
50 - (passengers % 50)
+ 1
Listen to Eve's advice. I can't explain it better
+ 1
That's it, I understand the task! imagine the total number of passengers for example 176 people. one bus carries 50 people at a time. we need to calculate the number of available seats only in the last bus. so we need to subtract from 176 three times 50 (three buses will leave full). and total number of seats last we need to deduct the remainder 176 - 150
+ 1
#include <iostream>
using namespace std;
int main() {
//ваш код
int bus = 50;
int people;
cin >> people;
int val = people % bus;
int va = bus - val;
cout << va;
}
0
I want to know how come you came up with this formula ?
(250 - passengers) % 50
0
Hi! instead of 250, you should use a variable - the total number of passengers
0
hello every one
I need your help 💚
0
In my opinion we must write the code conform to the user requirements. We just need to give improvement advice in case the business process and result expected not confirm. Except stated others. I write my code int empty_seats = passengers%50. It passed all test case. But in Loan calculator, my code only passed 3 of 5 test case. Confusing. The same thing is also happens in new driving license code. I passed 4 of total overall 5.
0
Hi! so you passed the credit calculator and the driver's license? can I see your code? In what language do you decide?
- 1
Martin Taylor
I think that will just be fine even if the input is multiple of 50.
Because the problem is asking for the free seats in the last bus, it is okay to have 50 free seats, (full capacity).
50 - (passengers % 50)
50 - (200 % 50)
50 - 0
= 50
It means that the last bus has 50 seats available, so we can still wait for the 50 passengers.
EDIT:
I think you're right if it is from her formula.
(passengers - 200) % 50
(250 - 200) % 50
50 % 50
= 0
- 1
Hi
- 1
X=3
num=17
print(num%3)
- 1
The point' is to determine number of empty seat in the last bus. You must remember that for every departure to the destination, bus always take a maximum passengers can be transported, which equal to 50 passenger. If bus total capacity 50 then available total passengers is less than capacity, bus only transport total passengers on only one departure and there is a Remaining empty seats 50-total Passengers waiting in queue to be transported to the destination. If Passengers is > 50 say 51, thus there will be 2 time departure which means there are 2 busses will transport the passenger, and the last bus only transport 1 passenger. So there are 50-1 or 49 empty seats remaining in the last bus departure. Thank you.
- 1
Math is easy only find your interest and start learning it because in coding this subjects are most helpful:
( I ) Physics
( II ) Chemistry
( III ) Math😉😉☺️☺️☺️😄😄😄😄😄😄☺️☺️😉😉😉
- 2
What is the output of this code?
x=3
num=17
print(num%3)
- 3
Hjdb
- 3
HLO