+ 4

# Help me to solve this....only hint can also work

You are making a program for a bus service. A bus can transport 50 passengers at once. Given the number of passengers waiting in the bus station as input, you need to calculate and output how many empty seats the last bus will have. Sample Input: 126 Sample Output: 24 Explanation: The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty.

20 ответов

+ 6

I see. You can use directly share button from your code bits =)
Anyway, may I know what is the purpose of the ing variable? Also one small note: if sub is modulus 50 of p, then using modulus on sub won't change its value as the value is already smaller than 50 =)

+ 9

The math behind it is
W - waiting passengers, input
T - max passengers per transport, 50
O - output, how many empty seats will last bus have
We can use modulus on the waiting passengers, by this we will receive amount of passengers who will be using the last bus: W%T, and now we only need to know how many empty seats will the last bus have. We can put this together and: O=T-(W%T) should be our result =)

+ 3

Sure, take your time! =)

+ 3

Awesome, I'm glad!
You're welcome =)

+ 3

Using % here will get the last no. Of persons standing
N then less it from total 50
😊🌻💙
#include <iostream>
using namespace std;
int main() {
//your code goes here
int waiting;
cin>>waiting;
int last;
last=waiting%50;
cout<<50-last;
return 0;
}

+ 2

#include <iostream>
using namespace std;
int main() {
int a;
cin>>a;
int b=50;
int c=a%b;
int d=b-c;
cout<<d<<endl;
return 0;
}

+ 1

Heya,
please tell me your thoughts first so I can give you a hint based on that =)

+ 1

I see, can you please link your code here?
I'm sure you're not far from the solution =)

+ 1

Ing is to count the remaining seats in bus....let me try it once again

+ 1

It really worked thanku thanku thanku sooo much

+ 1

If I remember well, you have to reach specific level to be able to send messages

+ 1

Oh right....... that's why I am not able to reply your message

0

I have used modulus%....but still it doesn't work

0

#include <iostream>
using namespace std;
int main() {
//your code goes here
int p, sub,rem,ing,gut;
cin>>p;
sub=p%50;
rem=sub%50;
ing=50%rem;
p-50;
cout<<50%p;
return 0;
}

0

I have done this..... don't mind variables

0

One more thing.......i can't message anyone because it shows that my account is not activated......but i have already activated it....what should i do.......can you help a little more?

- 1

guys check out my codeing and I'm asking to look for the one that has 50 lines

- 1

waiting=int(input())
remainingSeat = waiting%50
print (50-remainingSeat)

- 1

Psngr=input()
Psngr2=int(psngr/50)
Psngr3=50-(psngr-psngr2*50)

- 1

Alternative
a --> number of passengers at the bus station.
a%50 you get number of passengers left at the bus station.
50 -(a%50) You will the number of empty seats of the last bus after taking the rest of the left passengers.
int b = 50 - (a%50);
cout << b;