算法
文章平均质量分 78
parafish_0
这个作者很懒,什么都没留下…
展开
-
Python练习
Codingame 上打代码冲突 上题 Paint is a magical tool and birthplace to amazing early 2000s’ artists. One functionality, in particular has revolutionized the way to make art: “Fill the color”. This feature allows to change the color of a pixel and all neighboring pi原创 2021-06-09 20:15:10 · 133 阅读 · 2 评论 -
前缀和算法
前缀和 1、一维前缀和 前缀和其实就是数列求和公式 基本思路: a[1]+a[2]+…+a[n]=s[n] 求出s[i]后利用s[i]求 a[r]+a[r+1]+…+a[l]=s[l]-s[r-1] 例题: 输入一个长度为n的整数序列。 接下来再输入m个询问,每个询问输入一对l, r。 对于每个询问,输出原序列中从第l个数到第r个数的和。 输入格式 第一行包含两个整数n和m。 第二行包含n个整数,表示整数数列。 接下来m行,每行包含两个整数l和r,表示一个询问的区间范围。 输出格式 共m行,每行输出一个询原创 2021-06-02 21:08:02 · 331 阅读 · 0 评论