### Taha1506's blog

By Taha1506, history, 5 months ago,

In today's contest I used (1<<k) to denote $2^k$ but.It turned out that (1<<k) won't generate long long values so I got time limit exceeded in test three.Then I decide to implement power using multiply and return both the power and the number itself but it take more amount of code and I used to spend many time debugging it.Any suggestions?

• -3

 » 5 months ago, # |   +75 Bruh use 1ll << k
•  » » 5 months ago, # ^ |   0 I did it here:100370277But it didn't work.Am I missing something?
•  » » » 5 months ago, # ^ | ← Rev. 2 →   +3 I changed your 1<
•  » » » » 5 months ago, # ^ |   0 Oh I see I should have changed both (1<
•  » » 5 months ago, # ^ |   0 Ha ha , once upon a time, I used to think what the hell is this 1LL, then faced the same problem as above some days later, realized how important it is...
 » 5 months ago, # |   +5 Using $1LL$ << $k$ will generate long long data type values.
 » 5 months ago, # |   -30 Very weird that 1770 rated doesn't know this.
•  » » 5 months ago, # ^ |   +21 Not that weird. When I learned that my "true" rating was surely above 1770. In general rating and knowledge of language features are not as correlated as one might think.
 » 5 months ago, # |   +31 As to why: from the language's perspective, there is integer promotion (for example, when we have (char a) (short b), both are promoted to an int). Promoting to a long long by default would be a very costly choice, at least for 32-bit programs. And the compiler would have a very hard time guessing whether a particular operation should result in long long instead of int, and often guess wrong anyway. So it just doesn't try anything of the sort.Interestingly, in (int a) << (long long b), the result is still an int`. And the result when not ($0 \le b < 32$) is undefined behavior.