You are viewing a single comment's thread. Return to all comments →
No need for repeated subtractions or loops. It's purely O(1) (just straightforward formula split in two parts, two calculations).
int q = ((3-(N%3))%3) *5; if (N-q < 0) cout << -1 << endl; else cout << string(N-q,'5') << string(q,'3') << endl;
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and The Beast
You are viewing a single comment's thread. Return to all comments →
No need for repeated subtractions or loops. It's purely O(1) (just straightforward formula split in two parts, two calculations).