HDU 3784 继续xxx定律 HDU 2578 Dating with girls(1) 做3748之前要先做xxx定律  对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数变为1为止. 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数,5,8,4,2称为覆盖数.现在输入n个数字a[i],根据关键数与覆盖数的理论,我们只需要验证其中部分数就可以确定所有数满足xxx定律,输出输入的n个数中的关键数.如果…
HDU 4352 XHXJ's LIS HDU 题目大意 给你L到R区间,和一个数字K,然后让你求L到R区间之内满足最长上升子序列长度为K的数字有多少个 solution 简洁明了的题意总是让人无从下手 数字--数位DP 根据题意定义数组 第一维:数位 第二维:数位状态01串 第三维:个数K的大小 说说心路历程: 写的时候没有注意到前导零的可能型(通过看大佬的blog发现的 问题就是如何进行状态转移(手动@LC参考了LC的题解 我们用一个长度为10的二进制数表示数字几有没有被选到 如果为0,则表…
Decision 题意 从 \([0,t]\) 中等概率的选取两个数字 \(v_1,v_2\), 定义序列 \(X\) 有 \(X_0=v1+v2,X_{n+1}=(aX_n+c) \mod m\).如果 \(X_{|v1-v2|}\) 是偶数,则获胜,求获胜概率 范围:\(2\le m \le 10^6,0\le a,c \lt m, 0\le t \lt \frac{m}{2}\) 分析 枚举 \(sum = v_1+v_2\) 的值,考虑 \(dis = |v_1-v_2|\) 的可能取值…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5294   题意:给你n个墓室,m条路径,一个人在1号墓室(起点),另一个人在n号墓室(终点),起点的那个人只有通过最短路径才能追上终点的那个人,而终点的那个人能切断任意路径. 第一问——终点那人要使起点那人不能追上的情况下可以切的最少的路径数,输出最少的路径数 第二问——起点那人能追上终点那人的情况下,终点那人能切断的最多的路径数,输出最多的路径数 思路:要使起点那人无法追上,只要使他的最短路径不存…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5319 Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 826    Accepted Submission(s): 383 Problem Description Mr. Hdu is an painter, as we al…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5326 Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 583    Accepted Submission(s): 392 Problem Description It’s an interesting experience to…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5361 题意:最短路.求源点到全部点的最短距离.但与普通最短路不同的是,给出的边是某点到区间[l,r]内随意点的距离. 输入一个n,代表n个点,输入n个l[i],输入n个r[i],输入n个c[i]. 对于i,表示i到区间[i - r[i]],i - l[i]]和区间[i + l[i],i + r[i]]内的随意点的距离为c[i]. 求1到各个点的最短距离. 思路:若建边跑最短路的话,由于边过多,所以不可行…
题目链接:pid=5402">http://acm.hdu.edu.cn/showproblem.php?pid=5402 题意:给出一个n×m的矩阵,位置(i.j)有一个非负权值. 每一个点仅仅能经过一次.求从(1.1)到(n.m)权值总和最大的和.还需输出路径. 思路:由于走的点越多越好,所以得到规律,当n,m随意一个为奇数时.均能够走全然部点. 当n,m全为偶数时,当点(i.j)的i和j不同奇偶时,则除了(i,j)这个点均能够走完剩下的全部点. 剩下模拟就可以. n,m当中一个为奇数…
题目链接:pid=4950http://acm.hdu.edu.cn/showproblem.php?pid=4950">http://acm.hdu.edu.cn/showproblem.php?pid=4950 Monster Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 220    Accepted Submission…
题目链接:pid=5317" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=5317 Problem Description Mr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with…
题目链接 给n个数, 定义一个运算f[l,r] = gcd(al, al+1,....ar). 然后给你m个询问, 每次询问给出l, r. 求出f[l, r]的值以及有多少对l', r' 使得f[l, r] = f[l', r']. 第一个很简单, 用倍增的思想就可以了. 然后是第二个, 我们枚举每一个左端点i, 显然f[i, j]是只降不增的. 那么我们可以二分找到所有使得f[i, j]下降的值j. 因为gcd每次至少变为原来的二分之一, 而ai最大为1e9. 所以最多只有log2(1e9)个…
Front compression Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 158    Accepted Submission(s): 63 Problem Description Front compression is a type of delta encoding compression algorithm wher…
Terrorist’s destroy Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 24    Accepted Submission(s): 6 Problem Description There is a city which is built like a tree.A terrorist wants to destroy th…
Backup Plan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 93    Accepted Submission(s): 36Special Judge Problem Description Makomuno has N servers and M databases. All databases are synchroniz…
Building Fence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 171    Accepted Submission(s): 25Special Judge Problem Description Long long ago, there is a famous farmer named John. He owns a bi…
Integer Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22    Accepted Submission(s): 15 Problem Description Given n, k, calculate the number of different (unordered) partitions of n s…
Palindrome Sub-Array Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 173    Accepted Submission(s): 80 Problem Description A palindrome sequence is a sequence which is as same as its reversed or…
Warm up Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 90    Accepted Submission(s): 12 Problem Description N planets are connected by M bidirectional channels that allow instant transportatio…
Vases and Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 38    Accepted Submission(s): 10 Problem Description Alice is so popular that she can receive many flowers everyday. She has N v…
这题官方结题报告一直在强调不难,只要注意剪枝就行. 这题剪枝就是生命....没有最优化剪枝就跪了:如果当前连续切割数加上剩余的所有切割数没有现存的最优解多的话,不需要继续搜索了 #include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> # define MAX 33 using namespace std; stru…
题意摘自:http://blog.csdn.net/kdqzzxxcc/article/details/9474169 ORZZ 题意:给你N个花瓶,编号是0 到 N - 1 ,初始状态花瓶是空的,每个花瓶最多插一朵花. 然后有2个操作. 操作1,a b c ,往在a位置后面(包括a)插b朵花,输出插入的首位置和末位置. 操作2,a b ,输出区间[a , b ]范围内的花的数量,然后全部清空. 很显然这是一道线段树.区间更新,区间求和,这些基本的操作线段树都可以logN的时间范围内完成. 操作…
Nice boat Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 146    Accepted Submission(s): 75 Problem Description There is an old country and the king fell in love with a devil. The devil alw…
HDOJ--4869--Turn the pokers[组合数学+快速幂] 题意:有m张扑克,开始时全部正面朝下,你可以翻n次牌,每次可以翻xi张,翻拍规则就是正面朝下变背面朝下,反之亦然,问经过n次翻牌后牌的朝向有多少种情况.我们可以把正面朝上理解为1,反面朝上理解为0,那么可以理解为求01串的不同的组合方式有几种. 解题思路:我们可以知道,每张牌假设起始状态都为0,如果翻奇数次,该牌最后的情况是1,如果翻偶数次,该牌的最后情况为0.根据n次翻牌的个数找出1的个数的下限和上限,然后再在这个范围…
题意:已知昨天天气与今天天气状况的概率关系(wePro),和今天天气状态和叶子湿度的概率关系(lePro)第一天为sunny 概率为 0.63,cloudy 概率 0.17,rainny 概率 0.2.给定n天的叶子湿度状态,求这n天最可能的天气情况 分析:概率dp设 dp[i][j] 表示第i天天气为j的最大概率,pre[i][j]表示第i天天气最可能为j的前一天天气,dp[i][j]=max(dp[i-1][k]+log(wePro[k][j])+log(lePro[j][lePos[i]]…
Problem Description PM Room defines a sequence A = {A1, A2,..., AN}, each of which is either 0 or 1. In order to beat him, programmer Moor has to construct another sequence B = {B1, B2,... , BN} of the same length, which satisfies that:   Input The i…
解题报告:题目的意思是输入一个字符串,并规定,里面的“hehe”可以用"wqnmlgb"来代替,也可以不代替,问输入的这个字符串在经过相关的代替之后可以有多少种不同的形态.先打一个斐波那契数的表,f[1] = 1,f[2] =2....,然后从前往后扫一遍字符串,将一段连在一起的"he"一起计算,若这一段里面有 n 个 "he" ,然后这一段就有f[n]种不同的形态,然后一直这样扫下去,把每一段的状态数都相乘,就是最后的结果,不过,要注意的是用到…
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 8 Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbe…
Cut Pieces Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 133    Accepted Submission(s): 62 Problem Description Suppose we have a sequence of n blocks. Then we paint the blocks. Each block sho…
Swipe Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 455    Accepted Submission(s): 111 Problem Description “Swipe Bo” is a puzzle game that requires foresight and skill. The main character…
Palindrome subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65535 K (Java/Others)Total Submission(s): 88    Accepted Submission(s): 26 Problem Description In mathematics, a subsequence is a sequence that can be derived from…