摘要: 题意:维护一个整数序列,支持2种操作:1 a b k c将区间[a b]中满足(i-a)%k==0的数加上c;2 x查询第x个数的值。数据范围:整数个数N<=50000,操作次数Q<=50000,1<=k<=10分析:此题关键在于处理修改操作,我们发现修改是等间隔的,所以可以将数组拆开如下:k=1时,间隔为0:1 2 34 5 6 7 8 9 10……k=2时,间隔为1:1 3 5 7 9 ……2 4 6 8 10……k=3时,间隔为2:1 4 7 10……2 5 8 ……3 6 9 ……按以上拆法,可以得到55个整数序列,每次修改都是对其中一个序列进行的连续修改,由于 阅读全文
posted @ 2012-09-11 16:07 BeatLJ 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 题意:给n个正整数,代表n条边,现将n条边拼成一个三角形(每条边都要用到),问能组成多少个不同的三角形。View Code #include <stdio.h>#include <algorithm>#include <set>using namespace std;#define MP make_pairint l[15],n;int x[3];struct pro{ int ans,sum; set<pair<int,pair<int,int> > > Set; void init() { ans=sum=0; Set 阅读全文
posted @ 2012-09-11 15:45 BeatLJ 阅读(201) 评论(0) 推荐(0) 编辑