Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Use long long or int??

$
0
0

I recently submitted problem NUMGAME from easy practice question. http://www.codechef.com/problems/NUMGAME

I submitted the answer but by mistake I took n of integer type and not long long which it must be because its range is given to be 1000000000. However, to my surprise my solution got accepted. I think this must have been because of type promotion during type conversion by compiler. However, then I resubmitted my answer using long long and this time, although it got accepted, it took more memory and ran for more time. So, my question is if someone is getting less time and memory using simple integer instead of long long and the type promotion is always helping in such why someone would have the need to use long long? Why don't we use integer directly everytime even if takes less space and the compiler converts it internally? My solution using integer: http://www.codechef.com/viewsolution/2595553 My solution using long long: http://www.codechef.com/viewsolution/2595545


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>