Блог пользователя iamstg

Автор iamstg, история, 10 лет назад, По-английски

I was submitting the solution for Round #362 Div2 Problem E :

http://mirror.codeforces.com/contest/697/problem/E

I got WA on Test#4 on this submission : http://mirror.codeforces.com/contest/697/submission/19150824 I had typecasted every possible places where I felt overflow could occur with long long. I submitted many times but it gave wrong answer with typecast.

Then I submitted using 1ll in multiplication instead of typecast in this submission and it got accepted: http://mirror.codeforces.com/contest/697/submission/19150943

My question is why does typecasting not work and what is the difference between typecasting and 1ll?? Also when to use which because many of the solutions I coded before used typecasts and it worked well on various judges including Codeforces until I encountered this case for the first time.

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

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

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

You're only typecasting expressions that have been of type long long already (see http://mirror.codeforces.com/contest/697/submission/19151715). You don't need any of the casts.