QQpet exploratory park(DP)】的更多相关文章

QQpet exploratory park Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet exploratory park…
  A - QQpet exploratory park HDU - 1493 Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet…
题目大意: 一共有61个位置,标记为0~60.其中有10个重要位置,分别为:5, 12, 22, 29, 33, 38, 42, 46, 50 and 55. 有一个筛子,一共6个面,标有1~6.摇到几走几步,开始的位置是在0,一共可以要10次. 输入筛子摇出每个面的概率,输出经过这10个重要位置的概率. 题解: 概率DP问题,定义dp[i][j]为第i次摇筛子,处在位置j处.状态转移方程dp[i][j]=dp[i][j]+dp[i][j-k]*arr[k](1<=k<=6). 位置j处的答案…
超水的动态规划.最后要对概率求Sigma. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 61 #define MAXK 11 double dp[MAXK][MAXN]; ]; ] = {, , , , , , , , , }; int main() { int t; int i, j, k, p; #ifndef ONLINE_JUDGE freopen("data…
[题目]题意:N个城市形成一棵树,相邻城市之间的距离是1,问访问K个城市的最短路程是多少,共有M次询问(1 <= N, M <= 100000, 1 <= K <= N). [思路] 访问K个城市的路线: 可以发现它由一条主线和若干支线构成,并且主线上的边只用访问一次,而支线上的边必须且只用访问两次.而题目给定的是一棵树,那么访问K的城市就必须且仅需要走K-1条边.总边数是固定的,我们只需要保证主线最长即可,所以就是在树中找最长链. [找最长链]树形dp,dp[i]表示他的子树的最…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607 首先考虑找一条最长链长度k,如果m<=k+1,那么答案就是m.如果m>k+1,那么最长链上还有其他分支,来回走一遍,因此答案为2*m-k-1...求最长链可以DP,两次BFS或者DFS等.. //STATUS:C++_AC_453MS_3524KB #include <functional> #include <algorithm> #include <iost…
题目描述 公园里有$n$个雕像,有$n-1$条道路分别连接其中两个雕像,任意两个雕像可以直接或间接相连.现在每个景点$i$聚集着$P_i$只鸽子,旅行家手里有$v$数量的面包屑. 一旦旅行家在雕像$i$撒下$1$单位面包屑,那么相邻的雕像的鸽子就都会飞到雕像$i$来觅食. 时间线是这样的:首先,旅行家到达雕像$i$并与$P_i$鸽子会面.然后,他放下$1$单位面包屑.他离开雕像.在旅行家到达下一座雕像之前,来自相邻雕像的鸽子移动到雕像$i$(所以这些鸽子不计入他遇到的鸽子数).注意旅行家每到一达…
题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered wit…
C. Coloring Trees   ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right…
传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They wal…
题目链接: C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided…
[HNOI 2007]神奇游乐园 #include <bits/stdc++.h> #define maxn 110 using namespace std; typedef long long ll; int n, m; int a[maxn][maxn]; ll ans = -1ll << 60; #define M 2000010 #define mod 997 struct Hashmap{ ll st[M]; int h[1000], size, nxt[M]; ll f…
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n fr…
dp类:A - Bridging signals ZOJ 3627 POJ1631 HDU1950给出一个从1-n的数字排列,求最长上升子序列长度.直接说解法吧.新开一个数组d,d[i]表示的是能构成长度为i的上升子序列的在原序列中最后的那个数值.程序的主要过程:当循环到第i个的时候,如果原序列中的第i个数值大于之前d中保存的上升序列中长度最长的那个最后的值,那么,就把当前记录的最长的子序列的长度+1,然后把这个值加到d的末尾:如果不大于,那么就从前面二分找到这个值,d中的序列一定是有序的,找到…
http://codeforces.com/contest/711 C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where…
C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be…
转载请注明原文地址:http://www.cnblogs.com/LadyLex/p/7326874.html 最近搞了一下插头DP的基础知识……这真的是一种很锻炼人的题型…… 每一道题的状态都不一样,并且有不少的分类讨论,让插头DP十分锻炼思维的全面性和严谨性. 下面我们一起来学习插头DP的内容吧! 插头DP主要用来处理一系列基于连通性状态压缩的动态规划问题,处理的具体问题有很多种,并且一般数据规模较小. 由于棋盘有很特殊的结构,使得它可以与“连通性”有很强的联系,因此插头DP最常见的应用要数…
park作为今年noipday1最后一道题还是相比前面几道题还是有点难度的 首先你可以思考一下,第一天dp不见了,再看一下这题,有向图,看起来就比较像一个dp,考虑dp方程,首先肯定有一维是到哪个节点,还有一维肯定与路径长度有关,显然第二位就记录超过最短路多少. 这样我们可以找到dp方程,首先枚举一个kk(0<=kk<=k),按拓扑序枚举每一个点,枚举以这个点为起点的路径,如果这条路在最短路上,那么dp[v][kk]+=dp[u][kk],else 如果dis[u]+kk+路径长度<=d…
[BZOJ2310]ParkII Description Hnoi2007-Day1有一道题目 Park:给你一个 m * n 的矩阵,每个矩阵内有个权值V(i,j) (可能为负数),要求找一条回路,使得每个点最多经过一次,并且经过的点权值之和最大,想必大家印象深刻吧. 无聊的小 C 同学把这个问题稍微改了一下:要求找一条路径,使得每个点最多经过一次,并且点权值之和最大,如果你跟小 C 一样无聊,就麻烦做一下这个题目吧. Input 第一行 m, n,接下来 m行每行 n 个数即. V( i,j…
C. Coloring Trees time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be…
B. Om Nom and Dark Park Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526/problem/B Description Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living a…
Disney's FastPass Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4114 Description Disney's FastPass is a virtual queuing system created by the Walt Disney Company. First introduced in 1999 (thugh the idea of a…
题目链接:https://vjudge.net/problem/CodeForces-922E E. Birds time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Apart from plush toys, Imp is a huge fan of little yellow birds! To summon birds, Im…
HDU#4607. Park Visit 题目描述 Claire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the park are connected by exactly (N-1) undirected paths, and Claire is too tired to visi…
[POJ 2750] Potted Flower(线段树套dp) Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4566   Accepted: 1739 Description The little cat takes over the management of a new park. There is a large circular statue in the center of the park, surrou…
彻彻底底写到自闭的一个专题. 就是大型分类讨论,压行+宏定义很有优势. 常用滚动数组+哈希表+位运算.当然还有轮廓线. Formula 1: 经过所有格子的哈密顿回路数. 每个非障碍点必须有且仅有2个插头(含上下左右). 若左上都没有,那么新建两个插头1和2. 若左上只有一个插头,那么它就向右下方向之一延伸. 若左上都有,那么不建新插头. 如果是左1上2,那么就是形成了一条回路,当且仅当在全图右下角更新答案. 如果都是1,那么就要把右边的两个2改成一对插头,就是把靠右的一个1插头匹配的2插头改为…
洛谷 CF1193A Amusement Park 洛谷传送门 题目翻译 有一个游乐场有一个好玩的项目:一些有向滑梯可以将游客从一个景点快速.刺激地传送到另一个景点.现在,你要帮游乐场老板来规划一个造滑梯的项目. 滑梯只能从海拔高的地方向海拔低的地方滑.老板原定的方案已经给出,你的工作是反转某些滑梯的方向(可以反转全部的或一个都不转),并为每个景点指定一个海拔高度,使得每一个滑梯都能下山,那么这个方案是合法的.其成本是要反转的滑梯的总数.对于老板给定的方案,你需要算出所有合法方案的成本总和.由于…
C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where ntrees grow. They decided to be n…
题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A year ago on the bench in public park Leha found an array of n numbers. L…
网页链接:点击打开链接 Apart from plush toys, Imp is a huge fan of little yellow birds! To summon birds, Imp needs strong magic. There are n trees in a row on an alley in a park, there is a nest on each of the trees. In the i-th nest there are ci birds; to summ…