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!!
https://mirror.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.
int cnt = 0; while(S){ cnt++; S/=X; } cout << cnt << endl;