Matryoshka Dolls This is the problem I am stuck on. I wrote the source code in C++, which is down below. It failed on the 2nd test.

```
#include<iostream>
using namespace std;
int main(){
int s, x;
cin >> s >> x;
cout << (s-x)/x << endl;
}
```

If you have some time to spare, please help me. Thank you!!

What you did was coming up with an equation, although I have not judged it but from reading the problem statements I think what you should be doing is count how many times can

Sbe divided byXuntil there is no remainder left and the that count shall be the answer.I am terribly sorry, but I couldn't understand your advice. Could you specify that a little bit more, please? I'm so sorry. My ability to understand is probably extremely low.

It is something like this:

while(s) { s/=x' cnt++; }

You are checking how many times you can divide the size with x or rather say you are checking the number of dolls that can be nested.

https://codeforces.com/gym/102267/submission/59611271

As mentioned, the idea is so simple. The statement of problem clearly says what you need to do. Initially you have size S, next one should be S/X according to the statement, Then the next one is (S/X)/X, So what you need to calculate is logarithm S to the base X. This can be done using while loop.

Codeint cnt = 0; while(S){ cnt++; S/=X; } cout << cnt << endl;

You are finding (s/x)-1. But for each time, you should make s=/x and increase the answer(it should be 1 at the beginning). Because it says the doll <= the doll holds that doll/x.