Sherlock and The Beast

  • + 0 comments

    C++ solution :

    void decentNumber(int n) {
        int tmp;
        for (int x=0;x<=n/5;x++)
        {
            if (!((n-x*5)%3))
            {
                tmp=(n-x*5)/3;
                while(tmp--)    cout << 555;
                while(x--)  cout << 33333;
                cout << endl;
                return;
            }
        }
        cout << -1 << endl;
        return;
    }