HDU 5480:Conturbatio 前缀和】的更多相关文章

Conturbatio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5480 Description There are many rook on a chessboard, a rook can attack the row and column it belongs, including its own place. There are also many quer…
Conturbatio Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 786    Accepted Submission(s): 358 Problem Description There are many rook on a chessboard, a rook can attack the row and column it be…
区间求和不更新,开个数组记录一下前缀和就可以了 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; +; int R[maxn],C[maxn]; int sumR[maxn],sumC[maxn]; int main() { int T; scanf("%d",&T); while(T--) { i…
Conturbatio Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 232    Accepted Submission(s): 108 Problem Description There are many rook on a chessboard, a rook can attack the row and column it b…
题意:如果一个点,则这点的横竖皆被占领,询问矩阵是否全被占领. 思路:将被占领的x,y标记为1,用x表示1 - i的和 如果x轴的差为 x2 - x1 + 1则表示全被占领,y轴同理 #include <cstdio> #include <cstring> #include <algorithm> #include <functional> #include <vector> #include <queue> typedef long…
题意: 给出一个字符串,在所有长度大于1的前缀中,求所有的周期至少为2的周期串,并输出一个周期的长度以及周期的次数. 分析: 有了上一题 HDU 3746 的铺垫,这道题就很容易解决了 把next求出来,然后逐个判断即可. #include <cstdio> #include <cstring> + ; char p[maxn]; int n, next[maxn]; void get_next() { , j = ; next[] = -; while(j < n) { |…
拍照 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5714 Description 小明在旅游的路上看到了一条美丽的河,河上有许多船只,有的船只向左航行,有的船只向右航行.小明希望拍下这一美丽的风景,并且把尽可能多的船只都完整地拍到一张照片中. 小明位于河的边上,并且可以在河边的任意位置进行拍照,照相机的视野恰好为90度角,只能以垂直于河边的方向进行拍照.河上的船只全都可看作是平行于河边的一条线段,跟河边的距离各不相同,有的正在向左移动,有的正…
题意:给出一串数列,这串数列的gcd为1,要求取出一个数使取出后的数列gcd最大. 题解:可以通过对数列进行预处理,求出从下标为1开始的数对于前面的数的gcd(数组从下标0开始),称为前缀gcd,再以类似的方式求出后缀gcd,然后从第一个数开始枚举取出后的gcd(这个数的前缀gcd与后缀gcd的gcd).找出最大的gcd数即可. 代码如下: #include<cstdio> #include<cstring> #include<algorithm> using name…
sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1126    Accepted Submission(s): 494 Problem Description Given a sequence, you're asked whether there exists a consecutive subsequence whose…
题意:给定\(k,b,n,m\),求\(\sum_{i=0}^{n-1}f(g(i))\) 其中\(f(i)=f(i-1)+f(i-2),f(1)=1,f(0)=0\),\(g(i)=k*i+b\) 令矩阵\(A\)为 \[ \begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix} \] 那么 \[ \begin{bmatrix} f(n+1) \\ f(n) \\ \end{bmatrix}=A^n \begin{bmatrix} 1 \\ 0 \\…