预计分数:100+0+60=160

实际分数:100+0+60=160

mmpT1数据错了。。。

T1遭遇

题目描述

你是能看到第一题的 friends呢。

—— hja

?座楼房,立于城中 。

第?座楼,高度 ℎ?。

你需要一开始选择座楼,跳。 在第 ?座楼准备跳需要 ??的花费。 每次可以跳到任何一个还没有过的楼上去。但是代价,另外一座楼的代价是两高度差绝对值 ,最后一次从楼上跳到地面不需 要代价(只能跳到地上一次)。为在不超过 要代价(只能跳到地上一次)。为在不超过 ?的情况下,最多跳几次楼。 (一座楼 只能 跳一次 ,且每次 跳楼 都要 计算 准备 的花费 )

输入输出格式

输入格式:

第一行个整数 ?,代表 楼的数量。

接下来一行 ?个整数代表 ??。

接下来一行 ?个整数代表 ℎ?。

最后一行个整数 ?。

输出格式:

一行个整数 代表答案 。

输入输出样例

输入样例#1: 复制

  1. 4
  2. 3 5 4 11
  3. 2 1
  4. 3 17
输出样例#1: 复制

  1. 3
  2. 【样例解释】
  3. 1号楼跳到 2号楼再跳到 3号楼是一种 可行 的方案

说明

对于 30%的数据, 1≤?≤5。

对于另外 20%的数据,所有 ℎ?相同。

对于另外 20%的数据, ??=0。

P104 zhx 遭遇

第 3 页 共 6 页

对于 100%的数据, 1≤?≤50,1≤??,ℎ?≤106,1≤?≤107。

不会做,不过70分的算法貌似比较好想

但是h相等的情况貌似写炸了,。。。

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<algorithm>
  6. #include<ctime>
  7. using namespace std;
  8. const int MAXN=;
  9. const int INF=0x7ffff;
  10. inline int read()
  11. {
  12. char c=getchar();int flag=,x=;
  13. while(c<''||c>'') {if(c=='-') flag=-;c=getchar();}
  14. while(c>=''&&c<='') x=x*+c-,c=getchar();return x*flag;
  15. }
  16. int n,bg;//kashi
  17. struct node
  18. {
  19. int c;
  20. int h;
  21. }a[MAXN];
  22. int comp(const node &a,const node &b)
  23. {
  24. return a.c<b.c;
  25. }
  26. int comp2(const node &a,const node &b)
  27. {
  28. return a.h<b.h;
  29. }
  30. int ans=;
  31. int vis[MAXN];
  32. int T;
  33. int dfs(int now,int spend,int have)
  34. {
  35. ans=max(ans,have);
  36. for(int i=;i<=n;i++)
  37. {
  38. if(vis[i]==&&spend+a[i].c+abs(a[now].h-a[i].h)<=T)
  39. {
  40. if(clock()-bg>=)
  41. {
  42. printf("%d",ans);
  43. exit();
  44. }
  45. vis[i]=;
  46. dfs(i,spend+a[i].c+abs(a[now].h-a[i].h),have+);
  47. vis[i]=;
  48. }
  49. }
  50. }
  51. int flagh=;//高度是否相同
  52. int flagc=;//花费是否都为0
  53. inline void solvec()//花费都为0
  54. {
  55. sort(a+,a+n+,comp2);
  56. for(int i=;i<=n;i++)//从每一个点往后跳
  57. {
  58. int nowjump=;
  59. int nowspend=;
  60. for(int j=i+;j<=n;j++)
  61. {
  62.  
  63. if(abs(a[j].h-a[j-].h)+nowspend<=T)
  64. {
  65. nowspend=abs(a[j].h-a[j-].h)+nowspend;
  66. nowjump+=;
  67. }
  68. ans=max(ans,nowjump+);
  69. }
  70. }
  71. }
  72. inline void solveh()
  73. {
  74. int nowjump=;
  75. int nowspend=-;
  76. if(a[].c<=T)
  77. {
  78. nowspend=a[].c;
  79. for(int i=;i<=n;i++)
  80. if(nowspend+a[i].c<=T)
  81. nowjump++,nowspend+=a[i].c;
  82. }
  83.  
  84. if(nowspend!=-) ans=max(ans,nowjump+);
  85. }
  86. int main()
  87. {
  88. // freopen("meet.in","r",stdin);
  89. // freopen("meet.out","w",stdout);
  90. bg=clock();
  91. n=read();
  92. for(int i=;i<=n;i++) a[i].c=read();
  93. for(int i=;i<=n;i++) a[i].h=read();
  94. T=read();
  95. sort(a+,a+n+,comp);
  96. for(int i=;i<=n;i++)
  97. if(a[i].c!=) flagc=;
  98. for(int i=;i<=n;i++)
  99. for(int j=;j<=n;j++)
  100. if(a[i].h!=a[j].h&&i!=j)
  101. flagh=;
  102. if(flagc) solvec();
  103. if(flagh) solveh();
  104.  
  105. for(int i=;i<=n;i++)
  106. if(a[i].c<=T)
  107. vis[i]=,dfs(i,a[i].c,);
  108. printf("%d",ans);
  109. return ;
  110. }

莫名其妙丢20分

正解:

1(by myl)

考虑跳楼的集合

一定会有∑Ci

按照高度排序

高度差的代价==h5-h1

枚举最矮的楼,最高的楼

按照C排序,一个一个的选

总花费Hj-Hi+Ci+Cj+∑选出来的Ci<=T的最大值

复杂度:$O(N^3logN)$

2(by zhx)

dp

按照从低向高排序

$f[i][j]$表示停留在i,已经跳了j栋楼,的最小花费

枚举下一次跳哪栋楼

$f[k][i+1]=min(  f[k][j+1],f[i][j]+C[k]+abs(hk-hi)  )$

复杂度:$O(n^3)$

统计答案的时候枚举i,j观察是否<=T

  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <queue>
  6. #include <deque>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <ctime>
  20. #include<cstring>
  21.  
  22. using namespace std;
  23.  
  24. int f[][];
  25.  
  26. struct rec
  27. {
  28. int d,t;
  29. rec(){}
  30. rec(int a,int b)
  31. {
  32. d=a;t=b;
  33. }
  34. bool operator<(const rec &a)const
  35. {
  36. return t<a.t;
  37. }
  38. }z[];
  39.  
  40. class GUMIAndSongsDiv1 {
  41. public:
  42. int maxSongs(vector <int> duration, vector <int> tone, int T) {
  43. int n=duration.size();
  44. for (int a=;a<n;a++)
  45. z[a]=rec(duration[a],tone[a]);
  46. sort(z,z+n);
  47. memset(f,0x3f,sizeof(f));
  48. f[][]=;
  49. f[][]=z[].d;
  50. for (int a=;a<n;a++)
  51. for (int b=;b<=a+;b++)
  52. if (!b) f[a][b]=;
  53. else
  54. {
  55. for (int c=;c<a;c++)
  56. f[a][b]=min(f[a][b],f[c][b-]+z[a].d+(b== ? : z[a].t-z[c].t));
  57. }
  58. int ans=;
  59. for (int a=;a<n;a++)
  60. for (int b=;b<=n;b++)
  61. if (f[a][b]<=T) ans=max(ans,b);
  62. return ans;
  63.  
  64. }
  65. };
  66.  
  67. //<%:testing-code%>
  68. //Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!
  69. // BEGIN KAWIGIEDIT TESTING
  70. // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
  71. bool KawigiEdit_RunTest(int testNum, vector <int> p0, vector <int> p1, int p2, bool hasAnswer, int p3) {
  72. cout << "Test " << testNum << ": [" << "{";
  73. for (int i = ; int(p0.size()) > i; ++i) {
  74. if (i > ) {
  75. cout << ",";
  76. }
  77. cout << p0[i];
  78. }
  79. cout << "}" << "," << "{";
  80. for (int i = ; int(p1.size()) > i; ++i) {
  81. if (i > ) {
  82. cout << ",";
  83. }
  84. cout << p1[i];
  85. }
  86. cout << "}" << "," << p2;
  87. cout << "]" << endl;
  88. GUMIAndSongsDiv1 *obj;
  89. int answer;
  90. obj = new GUMIAndSongsDiv1();
  91. clock_t startTime = clock();
  92. answer = obj->maxSongs(p0, p1, p2);
  93. clock_t endTime = clock();
  94. delete obj;
  95. bool res;
  96. res = true;
  97. cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
  98. if (hasAnswer) {
  99. cout << "Desired answer:" << endl;
  100. cout << "\t" << p3 << endl;
  101. }
  102. cout << "Your answer:" << endl;
  103. cout << "\t" << answer << endl;
  104. if (hasAnswer) {
  105. res = answer == p3;
  106. }
  107. if (!res) {
  108. cout << "DOESN'T MATCH!!!!" << endl;
  109. } else if (double(endTime - startTime) / CLOCKS_PER_SEC >= ) {
  110. cout << "FAIL the timeout" << endl;
  111. res = false;
  112. } else if (hasAnswer) {
  113. cout << "Match :-)" << endl;
  114. } else {
  115. cout << "OK, but is it right?" << endl;
  116. }
  117. cout << "" << endl;
  118. return res;
  119. }
  120. int main() {
  121. freopen("meet.in","r",stdin);
  122. freopen("meet.out","w",stdout);
  123.  
  124. vector<int> duration;
  125. vector<int> tone;
  126. int n,T;
  127. scanf("%d",&n);
  128. for (int a=;a<=n;a++)
  129. {
  130. int v;
  131. scanf("%d",&v);
  132. duration.push_back(v);
  133. }
  134. for (int a=;a<=n;a++)
  135. {
  136. int v;
  137. scanf("%d",&v);
  138. tone.push_back(v);
  139. }
  140. scanf("%d",&T);
  141. GUMIAndSongsDiv1 *obj;
  142. int answer;
  143. obj = new GUMIAndSongsDiv1();
  144. answer = obj->maxSongs(duration, tone, T);
  145. printf("%d\n",answer);
  146. /*bool all_right;
  147. all_right = true;
  148.  
  149. vector <int> p0;
  150. vector <int> p1;
  151. int p2;
  152. int p3;
  153.  
  154. {
  155. // ----- test 0 -----
  156. int t0[] = {3,5,4,11};
  157. p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  158. int t1[] = {2,1,3,1};
  159. p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  160. p2 = 17;
  161. p3 = 3;
  162. all_right = KawigiEdit_RunTest(0, p0, p1, p2, true, p3) && all_right;
  163. // ------------------
  164. }
  165.  
  166. {
  167. // ----- test 1 -----
  168. int t0[] = {100,200,300};
  169. p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  170. int t1[] = {1,2,3};
  171. p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  172. p2 = 99;
  173. p3 = 0;
  174. all_right = KawigiEdit_RunTest(1, p0, p1, p2, true, p3) && all_right;
  175. // ------------------
  176. }
  177.  
  178. {
  179. // ----- test 2 -----
  180. int t0[] = {1,2,3,4};
  181. p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  182. int t1[] = {1,1,1,1};
  183. p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  184. p2 = 100;
  185. p3 = 4;
  186. all_right = KawigiEdit_RunTest(2, p0, p1, p2, true, p3) && all_right;
  187. // ------------------
  188. }
  189.  
  190. {
  191. // ----- test 3 -----
  192. int t0[] = {9,11,13,17};
  193. p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  194. int t1[] = {2,1,3,4};
  195. p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  196. p2 = 20;
  197. p3 = 1;
  198. all_right = KawigiEdit_RunTest(3, p0, p1, p2, true, p3) && all_right;
  199. // ------------------
  200. }
  201.  
  202. {
  203. // ----- test 4 -----
  204. int t0[] = {87,21,20,73,97,57,12,80,86,97,98,85,41,12,89,15,41,17,68,37,21,1,9,65,4,67,38,91,46,82,7,98,21,70,99,41,21,65,11,1,8,12,77,62,52,69,56,33,98,97};
  205. p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  206. int t1[] = {88,27,89,2,96,32,4,93,89,50,58,70,15,48,31,2,27,20,31,3,23,86,69,12,59,61,85,67,77,34,29,3,75,42,50,37,56,45,51,68,89,17,4,47,9,14,29,59,43,3};
  207. p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  208. p2 = 212;
  209. p3 = 12;
  210. all_right = KawigiEdit_RunTest(4, p0, p1, p2, true, p3) && all_right;
  211. // ------------------
  212. }
  213.  
  214. if (all_right) {
  215. cout << "You're a stud (at least on the example cases)!" << endl;
  216. } else {
  217. cout << "Some of the test cases had errors." << endl;
  218. }
  219. return 0;*/
  220. }
  221. // END KAWIGIEDIT TESTING

鬼畜的正解

T2都市

题目描述

你是能看到第二题的 friends呢。

—— laekov

塔立于都市, 攀登上塔,能够到达更远的地方。但是需要破解谜 题。仍然有 ?个数,但并不给你 而是了?×?−12个数,代表它们两的 和。那么,这 ?个数是多少呢?

输入输出格式

输入格式:

一行个整数 ?。

接下来一行 ?×?−12个数,代表两之和。

输出格式:

第一行个整数 ?代表解的个数 。

接下来 ?行 ,每行 ,每?个数代表一组解,从小到大排列。的顺序 按照字典个数代表一组解,从小到大排列。的顺序 按照字典个数代表一组解,从小到大排列。的顺序 按照字典从大到小排列。

输入输出样例

输入样例#1: 复制

  1. 4
  2. 3 5 4 7 6 5
输出样例#1: 复制

  1. 1
  2. 1 2 3 4
输入样例#2: 复制

  1. 4
  2. 11 17 21 12 20 15
输出样例#2: 复制

  1. 2
  2. 4 7 8 13
  3. 3 8 9 12
  4. P104 zhx 都市
  5. 5 6

说明

对于 30%的数据, 1≤?≤5,?个数均不超过 10。

对于 60%的数据, 1≤?≤50,?个数均不超过 100。

对于 100%的数据, 1≤?≤300,?个数均不超过 108。

不会做,

最后没时间了,连暴力都没打。

正解

先对给出以及枚举的数的数进行排序

设枚举的数为$a_1,a_2$

给出的数为$b_1,b_2$

性质:

a1+a2==b1

a1+a3==b2

设a2+a3=x

枚举a2+a3等于b里面的哪个数

对于所有的ai,都进行这个操作

每次解除a1,a2,a3

时间复杂度:$O(n^4)≈O(n^3)$

  1. v#include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<algorithm>
  5.  
  6. using namespace std;
  7.  
  8. const int maxn=;
  9.  
  10. int n,m,res[maxn],ans[maxn][maxn],z[maxn*maxn],cnt;
  11.  
  12. bool use[maxn*maxn];
  13.  
  14. void check(int p)
  15. {
  16. memset(use,false,sizeof(use));
  17. if ((z[]+z[]+z[p])&) return;
  18. res[]=(z[]+z[]+z[p])/-z[p];
  19. res[]=z[]-res[];
  20. res[]=z[]-res[];
  21. use[]=use[]=use[p]=true;
  22. for (int a=,b=;a<=n;a++)
  23. {
  24. while (b<=m && use[b])
  25. b++;
  26. if (b>m) return;
  27. res[a]=z[b]-res[];
  28. use[b]=true;
  29. for (int c=;c<a;c++)
  30. {
  31. if (res[c]>res[a]) return;
  32. int v=res[c]+res[a];
  33. int p=lower_bound(z+,z+m+,v)-z;
  34. if (z[p]!=v) return;
  35. int px=p;
  36. while (px && z[px]==z[p])
  37. px--;
  38. px++;
  39. while (px<=m && z[px]==z[p] && use[px])
  40. px++;
  41. if (z[px]!=z[p] || use[px]) return;
  42. p=px;
  43. use[p]=true;
  44. }
  45. }
  46. cnt++;
  47. for (int a=;a<=n;a++)
  48. ans[cnt][a]=res[a];
  49. }
  50.  
  51. int main()
  52. {
  53. freopen("city.in","r",stdin);
  54. freopen("city.out","w",stdout);
  55.  
  56. scanf("%d",&n);
  57. m=n*(n-)/;
  58. for (int a=;a<=m;a++)
  59. scanf("%d",&z[a]);
  60. sort(z+,z+m+);
  61. for (int a=;a<=m;)
  62. {
  63. check(a);
  64. int b=a;
  65. while (b<=m && z[b]==z[a])
  66. b++;
  67. a=b;
  68. }
  69. printf("%d\n",cnt);
  70. for (int a=;a<=cnt;a++)
  71. for (int b=;b<=n;b++)
  72. {
  73. printf("%d",ans[a][b]);
  74. if (b==n) printf("\n");
  75. else printf(" ");
  76. }
  77.  
  78. return ;
  79. }

T3街灯

题目描述

你是能看到第三题的 friends呢。

—— aoao

街上的灯亮起,指引向着远方路 街上的灯亮起,指引向着远方路 街上的灯亮起,指引向着远方路 街上的灯亮起,指引向着远方路 街上的灯亮起,指引向着远方路 。每个街灯上都有一数, 每个街灯上都有一数, 每个街灯上都有一数, 每个街灯上都有一数, 每次询问, 每次询问, 第?个街灯到第 ?个街灯上的数模 ?等于 ?的有几个。

输入输出格式

输入格式:

第一行两个数 ?,?,代表街灯的个数 和询问。

接下来一行 ?个数,代表 街灯上的数。

接下来 ?行,每四个数 ?,?,?,?代表一组询问。

输出格式:

对于每次询问,输出一行代表答案 。

输入输出样例

输入样例#1: 复制

  1. 5 2
  2. 1 5 2 3 7
  3. 1
  4. 3 2 2 5 3 0
输出样例#1: 复制

  1. 2
  2. 1

说明

对于 30%的数据, 1≤?,?≤103。

对于另外 30%的 数据,每次询问?一样。

对于 100%的数据, 1≤?,?≤105,街灯上的数不超过 104,1≤?≤109。

30分是暴力

另外30分可以用莫队水。。

但是标程是用链表做的

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<map>
  6. #include<algorithm>
  7. using namespace std;
  8. const int MAXN=1e6;
  9. const int INF=0x7ffff;
  10. inline int read()
  11. {
  12. char c=getchar();int flag=,x=;
  13. while(c<''||c>'') {if(c=='-') flag=-;c=getchar();}
  14. while(c>=''&&c<='') x=x*+c-,c=getchar();return x*flag;
  15. }
  16. int n,m;
  17. int a[MAXN];
  18. struct node
  19. {
  20. int l,r,p,v,id;
  21. }q[MAXN];
  22. int out[MAXN];
  23. int flag=;//p是否都相等
  24. int ansout=;
  25. int mod=;
  26. int base[MAXN];
  27. //map<int,int>happen;
  28. int happen[*MAXN*+];
  29. int comp(const node &a,const node &b)
  30. {
  31. if(base[a.l]==base[b.l])
  32. return base[a.r]<base[b.r];
  33. else return base[a.l]<base[b.l];
  34. }
  35. inline void dele(int pos)
  36. {
  37. happen[a[pos]%mod]--;
  38. }
  39. inline void add(int pos)
  40. {
  41. happen[a[pos]%mod]++;
  42. }
  43. inline void modui()
  44. {
  45. int ll=,rr=-;
  46. int now=;
  47. for(int i=;i<=m;i++)
  48. {
  49. while(ll<q[i].l) dele(ll),ll++;
  50. while(ll>q[i].l) add(ll-),ll--;
  51. while(rr<q[i].r) add(rr+),rr++;
  52. while(rr>q[i].r) dele(rr),rr--;
  53. out[q[i].id]=happen[q[i].v];
  54. }
  55. for(int i=;i<=m;i++)
  56. printf("%d\n",out[i]);
  57. }
  58. int main()
  59. {
  60. // freopen("light.in","r",stdin);
  61. // freopen("light.out","w",stdout);
  62. n=read(),m=read();
  63. int p=sqrt(n);
  64. for(int i=;i<=n;i++) base[i]=(i-)/p;
  65. for(int i=;i<=n;i++) a[i]=read();
  66. for(int i=;i<=m;i++)
  67. {
  68. q[i].l=read();
  69. q[i].r=read();
  70. q[i].p=read();
  71. q[i].v=read();
  72. q[i].id=i;
  73. if(i>=&&q[i].p!=q[i-].p) flag=;
  74. }
  75. if(flag&&n>=1e3&&m>=1e3)
  76. {
  77. sort(q+,q+m+,comp);
  78. mod=q[].p;
  79. static map<int,int>happen;
  80. modui();
  81. return ;
  82. }
  83. for(int i=;i<=m;i++)
  84. {
  85. int ans=;
  86. for(int j=q[i].l;j<=q[i].r;j++)
  87. if(a[j]%q[i].p==q[i].v)
  88. ans++;
  89. printf("%d\n",ans);
  90. }
  91. return ;
  92. }

莫队

30分

暴力

60

把%p的余数扔到vector||链表||某个数据结构中

每次二分出l的位置和r的位置

空间复杂度:$O(N)$

100

对p分块

p<=100对于每一个询问预处理

p>100

考虑a[i]%p==v

的值为v+p.v+kp。。

枚举k,k<=100

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. const int maxn = ;
  8. const int maxv = ;
  9. const int bsz = ;
  10. const int maxb = ;
  11.  
  12. int n, m;
  13. int a[maxn], vb[maxb][maxb], ve[maxb][maxb];
  14. int xb[maxn], xe[maxn];
  15. int i_buf[maxn * maxb * ], tib;
  16.  
  17. void pre() {
  18. memset(ve, , sizeof(ve));
  19. memset(xe, , sizeof(xe));
  20. for (int i = ; i <= n; ++ i)
  21. ++ xe[a[i]];
  22. for (int i = ; i <= maxv; ++ i) {
  23. xb[i] = tib;
  24. tib += xe[i];
  25. xe[i] = xb[i];
  26. }
  27. for (int i = ; i <= n; ++ i)
  28. i_buf[xe[a[i]] ++] = i;
  29. for (int m = ; m <= bsz; ++ m) {
  30. for (int i = ; i <= n; ++ i)
  31. ++ ve[m][a[i] % m];
  32. for (int i = ; i < m; ++ i) {
  33. vb[m][i] = tib;
  34. tib += ve[m][i];
  35. ve[m][i] = vb[m][i];
  36. }
  37. for (int i = ; i <= n; ++ i)
  38. i_buf[ve[m][a[i] % m] ++] = i;
  39. }
  40. }
  41.  
  42. int queryb(int l0, int r0, int p, int k) {
  43. if (vb[p][k] == ve[p][k])
  44. return ;
  45. int *x1 = lower_bound(i_buf + vb[p][k], i_buf + ve[p][k], l0);
  46. int *x2 = upper_bound(i_buf + vb[p][k], i_buf + ve[p][k], r0);
  47. return x2 - x1;
  48. }
  49.  
  50. int querys(int v, int l0, int r0) {
  51. if (xb[v] == xe[v])
  52. return ;
  53. int *x1 = lower_bound(i_buf + xb[v], i_buf + xe[v], l0);
  54. int *x2 = upper_bound(i_buf + xb[v], i_buf + xe[v], r0);
  55. return x2 - x1;
  56. }
  57.  
  58. int querya(int l0, int r0, int p, int k) {
  59. int ans = ;
  60. for (int i = k; i <= maxv; i += p)
  61. ans += querys(i, l0, r0);
  62. return ans;
  63. }
  64.  
  65. int main() {
  66. freopen("light.in", "r", stdin);
  67. freopen("light.out", "w", stdout);
  68.  
  69. scanf("%d%d", &n, &m);
  70. tib = ;
  71. for (int i = ; i <= n; ++ i)
  72. scanf("%d", a + i);
  73. pre();
  74. while (m --) {
  75. int l, r, p, k;
  76. scanf("%d%d%d%d", &l, &r, &p, &k);
  77. if (p <= bsz)
  78. printf("%d\n", queryb(l, r, p, k));
  79. else
  80. printf("%d\n", querya(l, r, p, k));
  81. }
  82. }

正解

Day2上午解题报告的更多相关文章

  1. 「雅礼集训 2017 Day2」解题报告

    「雅礼集训 2017 Day2」水箱 我怎么知道这种题目都能构造树形结构. 根据高度构造一棵树,在树上倍增找到最大的小于约束条件高度的隔板,开一个 \(vector\) 记录一下,然后对于每个 \(v ...

  2. Day1上午解题报告

    预计分数:100+60+0=160 实际分数:100+30+20=150 T1立方数(cubic) 题目描述 LYK定义了一个数叫“立方数”,若一个数可以被写作是一个正整数的3次方,则这个数就是立方数 ...

  3. Day3上午解题报告

    预计分数:100+40+50=190 实际分数:100+40+50=190 T1 https://www.luogu.org/problem/show?pid=T15365 表示从来没做过博弈论的题, ...

  4. Day2下午解题报告

    预计分数:100+100+30=230 实际分数:100+100+30=230人品爆发&&智商爆发&&手感爆发 T3数据好水,,要是把数组开大一点的话还能多得10分,, ...

  5. Day5上午解题报告

    预计分数:100+40+30=170 实际假分数:0+0+0=0 CE*3 实际真分数:60+50+0=110 老师没把我的程序放的文件夹里面,于是..... T1 https://www.luogu ...

  6. Day4上午解题报告

    预计分数:50 +0+0=50 实际分数:50+0+10=60 毒瘤出题人,T3不给暴力分 (*  ̄︿ ̄) T1 https://www.luogu.org/problem/show?pid=T155 ...

  7. GX/GZOI2019 day2 解题报告

    GX/GZOI2019 day2 解题报告 题目链接 逼死强迫症 旅行者 旧词 t1 逼死强迫症 显然地,记 \(f(i)\) 为长度为 \(i\) 的木板的答案,可得: \(\\\) \[f(i)= ...

  8. 【NOIP2015】提高day2解题报告

    题目: P1981跳石头 描述 一年一度的“跳石头”比赛又要开始了!这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 N ...

  9. 【未完成0.0】Noip2012提高组day2 解题报告

    第一次写一套题的解题报告,感觉会比较长.(更新中Loading....):) 题目: 第一题:同余方程 描述 求关于x的同余方程ax ≡ 1 (mod b)的最小正整数解. 格式 输入格式 输入只有一 ...

随机推荐

  1. Playing With Stones UVALive - 5059 Nim SG函数 打表找规律

    Code: #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; ll ...

  2. Centos7(阿里云服务器)安装Anaconda的详细步骤与心得

    在本地安装Anaconda的各个版本的文章已经很多,但是感觉不是很详细,因此,在此发发自己在Centos7(阿里云服务器)安装Anaconda的心得和步骤: 注:需要注意的地方会用不同颜色区别. 1. ...

  3. 今日SGU 5.27

    SGU 122 题意:给你n个人,每个人有大于 N / 2(向上取整)的朋友,问你1这个人有一个书,每个人都想看,只能从朋友之间传递,然后最后回到了1这个人,问你 是否有解,然后有解输出路径 收获:哈 ...

  4. [Python] numpy fillna() for Dataframe

    In the store marketing, for many reason, one stock's data can be incomplete: We can use 'forward fil ...

  5. Android ImageView设置图片原理(下)

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 写完上一篇后,总认为介绍的知识点不多,仅仅是一种在UI线程解析载入图片.两种在子线程解析,在UI线程 ...

  6. 受不了Android SDK文档打开缓慢问题,自己开发简易脱机浏览器。

    google android sdk离线文档打开的时候特别慢,据说是要从谷歌官网拉取一些东西导致的.脱机浏览能够解决该问题.PC端能够使用firefox. 可是Android端貌似没有支持脱机工作的浏 ...

  7. Spring官方文档翻译——15.4 处理器映射(Handler mappings)

    15.4 处理器映射(Handler mappings) 注:以下将handler翻译成处理器 在Spring早先的版本号中,用户还须要在web应用上下文中定义处理器映射来配置请求(requests) ...

  8. Spark技术内幕:Client,Master和Worker 通信源代码解析

    Spark的Cluster Manager能够有几种部署模式: Standlone Mesos YARN EC2 Local 在向集群提交计算任务后,系统的运算模型就是Driver Program定义 ...

  9. shu_1171 十-&gt;二进制转换(输入输出控制)

    cid=1079&pid=19">http://202.121.199.212/JudgeOnline/problem.php?cid=1079&pid=19 分析:主 ...

  10. MySQL外键的介绍

    在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束. 1.MySQL中“键”和“索引”的定义相同,所以外键和主键一样也是索引的一种.不同的是MySQL会自动为所有表的主键进行索 ...