Sololearn: Learn to Code
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)
27th Feb 2021, 11:51 AM
noteve
noteve - avatar
+ 1
Listen to Eve's advice. I can't explain it better
27th Feb 2021, 12:02 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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
27th Feb 2021, 12:09 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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; }
1st Mar 2021, 3:01 AM
‎ Герман Папанов(הרמן פפנוב)‎
‎ Герман Папанов(הרמן פפנוב)‎ - avatar
0
I want to know how come you came up with this formula ? (250 - passengers) % 50
27th Feb 2021, 11:46 AM
Arsenic
Arsenic - avatar
0
Hi! instead of 250, you should use a variable - the total number of passengers
27th Feb 2021, 11:48 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
hello every one I need your help 💚
27th Feb 2021, 8:17 PM
محمد جلال
محمد جلال - avatar
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.
1st Mar 2021, 8:22 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
0
Hi! so you passed the credit calculator and the driver's license? can I see your code? In what language do you decide?
1st Mar 2021, 8:37 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
- 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
27th Feb 2021, 3:29 PM
noteve
noteve - avatar
- 1
Hi
28th Feb 2021, 3:48 AM
Rai Preti
Rai Preti - avatar
- 1
X=3 num=17 print(num%3)
1st Mar 2021, 4:12 AM
Maha Yahia
Maha Yahia - avatar
- 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.
1st Mar 2021, 4:21 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
- 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😉😉☺️☺️☺️😄😄😄😄😄😄☺️☺️😉😉😉
1st Mar 2021, 6:25 AM
Anurag Kumar
Anurag Kumar - avatar
- 2
What is the output of this code? x=3 num=17 print(num%3)
1st Mar 2021, 4:16 AM
Maha Yahia
Maha Yahia - avatar
- 3
Hjdb
28th Feb 2021, 12:20 PM
ఆగం హరీష్
ఆగం హరీష్ - avatar
- 3
HLO
28th Feb 2021, 2:07 PM
ارسلان ایشه
ارسلان ایشه - avatar