D. The Wu time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Childan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of "Wu" to the Kasoura…
不想欠题了..... 多打打CF才知道自己智商不足啊... A. Vladik and flights 给你一个01串  相同之间随便飞 没有费用 不同的飞需要费用为  abs i-j 真是题意杀啊,,,实际上我们只考虑01转换的代价一定为1如果目的地和起点相同  费用为0 不相同  肯定为1  因为0旁边必然有1 #include <cstdio> #include <iostream> #include <algorithm> #include <vector…
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer wit…
Codeforces 题目传送门 & 洛谷题目传送门 还是做题做太少了啊--碰到这种题一点感觉都没有-- 首先我们来证明一件事情,那就是存在一种合并方式 \(\Leftrightarrow\) \(\exist b_i\in\mathbb{Z}^+,\sum\limits_{i=1}^na_ik^{-b_i}=1\) 考虑充分性,倘若我们已经知道了 \(b_1,b_2,\dots,b_n\) 的值怎样构造合并的序列,考虑 \(B=\max\limits_{i=1}^nb_i\),这里有一个结论,…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
C. Subsequences     For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input   First line contain two integer values n and k (1…
求从1点出发,走遍所有的点,然后回到1点的最小代价. 每个点可以走若干遍. 如果每个点只能走一遍,那么设dp[i][s]为走完s状态个点(s是状态压缩),现在位于i的最小花费. 然后枚举从哪个点回到原点即可. 但是现在每个点不止走一次,那么状态就不好表示了,但是,我们可以用floyd处理出任意两点的最短距离. 这样子,可以用上面的方式求解了. #include <stdio.h> #include <string.h> #include <stdlib.h> #incl…
The Minimum Number of Variables 我们定义dp[ i ][ mask ]表示是否存在 处理完前 i 个a, b中存者 a存在的状态是mask 的情况. 然后用sosdp处理出,状态为state的a, 能组成的数字, 然后转移就好啦. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #…
题意:有n个菜,每个菜有个兴奋值,并且如果吃饭第i个菜立即吃第j个菜,那么兴奋值加ma[i][j],求吃m个菜的最大兴奋值,(n<=18) 分析:定义dp[status][last],status为每道菜的状态,1为吃,0为不吃,last为最后一个菜,dp[status][last],在status状态下最后吃last的最大兴奋值,然后枚举status去更新后面的状态,详细见代码 AC代码: #include <bits/stdc++.h> #define ll long long us…
[多校联考2019(Round 5)] [ATCoder3912]Xor Tree(状压dp) 题面 给出一棵n个点的树,每条边有边权v,每次操作选中两个点,将这两个点之间的路径上的边权全部异或某个值,求使得最终所有边权为0的最小操作次数. \(v \leq 15,n \leq 10^5\) 分析 首先把边权转化为点权.记一个点的点权为与它相连的所有边的边权和.当我们给一条路径上的边异或上某个值时,路径端点的点权被异或了1次,而路径上不是端点的点有两条边被异或了,相当于异或了2次,权值不变.因此…