When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

Night_Lord's blog

By Night_Lord, history, 3 years ago, In English

Hello, I got stuck here in this problem from cses Subarray Divisibility.I know that showing solutions is prohibited from cses but still I need some help here.My solution is here.Plz don't down vote me.If u can't help me just ignore this topic.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My approach to this problem would be to calculate a prefix sum mod N. This gives N possible values for each prefix sum. Count the number of occurrences of each prefix sum and then do the sum of those numbers choose 2. This problem is very similar to http://usaco.org/index.php?page=viewproblem2&cpid=595

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it

straight forward answer has geeks for geeks for this. Here is the link for this