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?
Bruh use 1ll << k
I did it here:100370277
But it didn't work.Am I missing something?
I changed your
1<<r
to1LL<<r
and got Accepted here is your changed submission.Oh I see I should have changed both (1<<r) to (1LL<<r).Thanks a lot.
Using $$$1LL$$$ << $$$k$$$ will generate long long data type values.
Very weird that 1770 rated doesn't know this.
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.
As to why: from the language's perspective, there is integer promotion (for example, when we have
(char a) <op> (short b)
, both are promoted to anint
). Promoting to along 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 inlong long
instead ofint
, 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 anint
. And the result when not ($$$0 \le b < 32$$$) is undefined behavior.