Блог пользователя Caramelio

Автор Caramelio, 5 лет назад, По-английски

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!!

  • Проголосовать: нравится
  • -11
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

Code