AnasAbbas's blog

By AnasAbbas, history, 8 years ago, In English

hello codeforces

i was wondering why do i have to use int while long long is more useful

today i found the answer :

using long long :http://codeforces.me/contest/543/submission/22092332

using int : http://codeforces.me/contest/543/submission/22092593

hope this help

thanks

  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by AnasAbbas (previous revision, new revision, compare).

»
8 years ago, # |
  Vote: I like it +3 Vote: I do not like it

See this. He struggled so hard for days. Told me his algorithm I was amazed. Finally I saw his code and felt so poor for him. I remember how much frustrated he was :P . int vs long long

»
8 years ago, # |
  Vote: I like it +7 Vote: I do not like it

int is much quicker than long long

»
8 years ago, # |
  Vote: I like it +16 Vote: I do not like it

Time Limit

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

First int is much quicker than long long, second long long use more memory.

»
8 years ago, # |
  Vote: I like it +16 Vote: I do not like it

Another reason: it's good to build the habit of thinking about the limits of the data type you are using. In some problems even long long may overflow if you don't handle operations properly. If you are in the habit of using long long always and never considering overflow, it's likely you won't realize it.

»
3 years ago, # |
  Vote: I like it -44 Vote: I do not like it

The probability of RTE due to integer overflow is far higher than MLE/TLE due to using long long instead of int unless you're doing a later div1 problem. Thus #define int long long or #define int int64_t should always be used IMO.

»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Additionally, on a 64 bit compiler, calculations done with 64 bit integers can actually speed up the program, as time doesn't need to be wasted casting 32-bit integers to 64-bit and vice versa.