You are viewing a single comment's thread. Return to all comments →
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 ...
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 →
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 ...