Project-Euler icon indicating copy to clipboard operation
Project-Euler copied to clipboard

08 done in cpp

Open LusiferAjay opened this issue 6 years ago • 8 comments

please merge my PR

LusiferAjay avatar Oct 10 '19 16:10 LusiferAjay

code taking too long.

AdarshRise avatar Oct 10 '19 18:10 AdarshRise

But my code Passed all the test cases of Project Eular. can you please tell me in which test case my code taking time?

LusiferAjay avatar Oct 10 '19 19:10 LusiferAjay

Well, I may not be able to help you with test case, but using " #include<bits/stdc++.h> " is like saying ' take every headerfile you can take', this way of coding is helpful where coding time matters, hence we compromise time-complexity for coding time. Try using only necessary header files.

AdarshRise avatar Oct 10 '19 19:10 AdarshRise

okk i get it thanks i will optimize my code

LusiferAjay avatar Oct 10 '19 19:10 LusiferAjay

can you review my code?.this time i used only required header files

LusiferAjay avatar Oct 10 '19 19:10 LusiferAjay

Well the problem arose with Max and Min, #include <limits.h> You might need this, but even with this code is taking long time, Try to think another way of solving this problem{ i would suggest }.

AdarshRise avatar Oct 10 '19 20:10 AdarshRise

please review my code

LusiferAjay avatar Oct 11 '19 03:10 LusiferAjay

Well, I appreciate your efforts. Let me give some direct Hint. to be on the same page, here is the problem. image As, you could see the given number is way big than any long long could handle. Hence, we should use char array { String } to store such large value.

And as you would be using such method of storing the numbers, keep the input within the code and avoid asking users for input. { because, some automated checks just check output and not input}.

and Int can't handle such long numbers.

AdarshRise avatar Oct 12 '19 01:10 AdarshRise