Advertisement
wavec022

summation stuff

Feb 23rd, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. Summation rule thing?
  2.  
  3. // given array of length n:
  4.  
  5. // var best = 0
  6. for(hi <- 1 to n) {
  7. for(lo <- 1 to hi) {
  8. // var sum = 0
  9. for(i <- lo to hi) {
  10. sum += a(i)
  11. }
  12. best = best max sum
  13. }
  14. }
  15. return best
  16.  
  17. sum_{hi=1..n} sum{lo=1..hi} sum{i=lo..hi} 1
  18.  
  19. sum_{hi=1..n} sum{lo=1..hi} hi-lo+1
  20.  
  21. https://gyazo.com/5cc9d1f57e76e34f3503337e996b95c9
  22. https://gyazo.com/642717f29acfb00d55896a40ec592a1f
  23. https://gyazo.com/88d9877837ed467ca6530cd275610435
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement