+ 1
What did I do wrong? Pls help
#include <iostream> using namespace std; int main() { //your code goes here int bus=50; int input, remainder; cin>> input; while(remainder > 49){ input - bus = remainder; } int bus % remainder = ans; cout << ans; return 0; }
5 Answers
+ 2
Equation must be in the right side of the assignment operator, and the result will stored left side of assignment operator .
That is, 
remainder = input - bus; (inside the while loop) 
int ans = bus% remainder;
+ 1
No need to use while loop you can directly get the result. 
What did I do wrong? Pls help
#include <iostream>
using namespace std;
int main() {
    //your code goes here
    int bus=50;
    int input, remainder;
    cin>> input;
    
    
          remainder=  input - bus  ;
       
          int  ans=  bus % remainder;
    cout << ans;
    return 0;
}
Here you go.
+ 1
Timeout is happening because if comparing an uninitialized variable. But i think there are some more mistakes. I tried to fix it for you, is that how the code should work?
#include <iostream>
using namespace std;
int main() {
    //your code goes here
    int bus=50;
    int input, remainder;
    cin >> input;
    remainder = input;
    while(remainder > 49) {
        remainder -= bus;
    }
    cout << bus - remainder;
    return 0;
}
But there is also a way without a loop, which performs much faster, especally for high input numbers.
Just modulo the input with the bus size to get passengers in the last/not full bus and substrakt that from the bus size to get the empty seats
+ 1
This was my solution without loop:
#include <iostream>
using namespace std;
int main() {
    //your code goes here
    int waiting;
    cin >> waiting;
    int left_seat = 50 - waiting % 50;
    cout << left_seat;
    
    return 0;
}
0
Thx but I'm getting a...
 "Timeout. Dumped core";






