srijon_32's blog

By srijon_32, history, 23 hours ago, In English

Here are my two submission for problem : 1158A - The Party and Sweets

  1. using accumulate function: 300047140

  2. using loop: 300047827

1st one giving wrong answer. Previously, the same thing happened with sqrt, and then I used binary search to find sqrt. So after this WA, I used a loop to get the sum, and now it's giving the correct answer. So where has this accumulate function gone wrong?

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

»
23 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

The initial value of the accumulate function must be a 64-bit data type; otherwise, an overflow will occur.

»
23 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

you need to declare initial value in accumulate function long long int if sum would needed long long int to fit in. Just simply use 0LL instead of 0

»
23 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

https://codeforces.net/contest/1158/submission/300054415

i hope this will resolve your issue .

if still you are having any issue do message me

happy coding

»
22 hours ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Use 0LL in accumulate function.

»
22 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks everyone for help. I got it.

»
19 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You have to use 0LL in accumulate function