题意:http://acm.hdu.edu.cn/showproblem.php?pid=5400 思路:预处理出每个点向左和向右的最远边界,从左向右枚举中间点,把区间答案加到总答案里面.由与可能与前面的区间重叠,需要减去重复的答案,由于左边界非降,所以重叠的区间长度很容易得到. #pragma comment(linker, "/STACK:10240000") #include <map> #include <set> #include <cmath&…
解题思路:这题看懂题目是很关键的,这个区间是等差数列,且公差为d1或d2, 特别注意单个数字也为等差数列.每次求出等差数列序列长度,然后   求出对应这种长度对应有多少种组合方式,累加起来就是结果.   注意要用long long,还有注意特判数据,如 5 -1 -1 ,5 4 3 2 1: 5 1 1, 1 2 3 4 5 ; 5 1 1, 1 1 1 1 1等. #include<cstdio> int main() { ], n, d1, d2; long long sum, cnt;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4675 题意:给出n,m,K,一个长度为n的数列A(1<=A[i]<=m).对于d(1<=d<=m),有多少个长度为n的数列B满足: (1)1<=B[i]<=m; (2)Gcd(B[1],B[2],……,B[n])=d: (3)恰有K个位置满足A[i]!=B[i]. 思路: i64 p[N]; void init(){    p[0]=1;    int i;    FOR1…
Y sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5297 Description Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hates those numbers which can be written as a^b (a, b are positive integers,2…
Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hates those numbers which can be written as a^b (a, b are positive integers,2<=b<=r),so he removed them all.Yellowstar calls the sequence that formed by…
题意:给定b数列.计算有多少种数列 a1,a2,...,an 满足条件 a1*a2*...*an=b1*b2*-*bn (ai>1). 解法:处理出b数列中出现的全部质因子的数量记录在map中,然后进行容斥计算: 代码: /****************************************************** * author:xiefubao *******************************************************/ #pragma…
Problem Mountain 题目大意 给定一张n*m的地图,由 . 和 X 组成.要求给每个点一个1~n*m的数字(每个点不同),使得编号为X的点小于其周围的点,编号为.的点至少大于一个其周围的点.   n<=5 , m<=5. 解题分析 考虑从1~n*m,从小到大依次填数,则如果某个位置编号为X且该位置还未填数,那么其周围的点均不能填数. 令dp[i][j]表示填到第i个数,状态为j . 令X的个数为cnt,那么 j ∈[ 0 , 1<<cnt). 一种情况为第i个数填在…
Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,13 in its prime factors is even. For instance, 18=2 * 3 * 3 is no…
题目链接 1.对于简单的版本n<=500, ai<=50 直接暴力枚举两个点x,y,dfs求x与y的距离. 2.对于普通难度n<=10000,ai<=500 普通难度解法挺多 第一种,树形dp+LCA 比赛的时候,我猜测对于不为1的n个数,其中两两互质的对数不会很多,肯定达不到n^2 然后找出所有互质的对数,然后对为1的数进行特殊处理.(初略的估计了下,小于500的大概有50个质数,将n个数平均分到这些数中,最后大概有10000*50*200=10^7) 对所有的非1质数对,采用离…
http://acm.hdu.edu.cn/showproblem.php?pid=5400 Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1151    Accepted Submission(s): 501 Problem Description A sequence b1,b2,⋯,bn a…