Sherlock and The Beast

  • + 1 comment

    Thank you very much for sharing the logic. I tried implementing it using cpp. Working fine for small cases.

    int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n, y, z, flag = -1; cin >> n; z = n; if(z <= 0) cout<<"-1\n"; else { if(z%3 == 0) { cout<< string(z,'5')<<"\n"; } while(z%3 != 0) { z -= 5; if(z<0) { cout<<"-1\n"; break; } else { cout <

    But it prints some crap for cases like 100,121,etc Did i messed some thing with your logic?? Any suggestions plz. Thank you ...