Please read the new rule regarding the restriction on the use of AI tools. ×

RHandarov's blog

By RHandarov, history, 7 years ago, In English

Hi Codeforces, I ask for help. Can I make a variable which is int type, but when it overflow, it convert to long long type. For example I make an integer variable x. I give max integer value on x. When I add 1 to x, I do not want to overflow. I want to make ( auto convert to) long long and continue with next number. Is it possible? I am sorry if I ask a stupid question.

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

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

just create the variable as a long long instead of as an int. You can do everything in the same way as with an int.