You are not logged in. Please login at to post your questions!


Codeforces k-Tree



I am unable to figure out why the above code (same logic as editorial) is leading to WA in test case 7. Could someone please help me identify where I am going wrong? I am guessing it's something to do with the mod, but not too sure.

asked 16 Sep '15, 17:21

sandy999's gravatar image

accept rate: 10%

You need to change the 'int' dp[104][2] to 'long long' dp[104][2]. This is because the temporary result stored in dp[i][k] is of data type int which overflows and wraps around to give negative results and hence wrong answer.

Accepted solution


answered 17 Sep '15, 07:13

devilhector's gravatar image

accept rate: 11%

edited 17 Sep '15, 07:13

Thanks @devilhector, I was making this mistake in another problem as well. Finally understood why the WA.

(17 Sep '15, 11:11) sandy9992★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 16 Sep '15, 17:21

question was seen: 3,519 times

last updated: 17 Sep '15, 11:11