题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数位DP:http://blog.csdn.net/libin56842/article/details/11580497 */ #include <cstdio> #include <iostream> #include <algorithm> #include <c…
Solution 注意取模!!! Code #include<bits/stdc++.h> #define mod 1000000007 #define LL long long using namespace std; int n, a, b; LL mpow(LL a, LL b) { LL ans = ; , a = a * a % mod) ) ans = ans * a % mod; return ans; } LL fac[], inv[], l[], t[]; void init…
刘汝佳蓝书上的题,标程做法是从终点倒着$spfa$,我是二分答案正着$spfa$判断可不可行.效果是一样的. [注意]多组数据建边一定要清零啊QAQ!!! #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; int S, T, p; struct Node { int v, nex; Node ( , ) : v ( v ), n…
题目 https://nanti.jisuanke.com/t/17118 题意 有n个点0,1,2...n-1,对于一个点对(i,j)满足i<j,那么连一条边,边权为i xor j,求0到n-1的最大流,结果取模,n<=1e18 分析 可以写个最大流对数据找规律,但没找出来…… 然后只能取分析了,首先最大流等价于最小割 明确一定,0->n-1这个要先割掉 然后我们贪心,希望有一些点割掉与0相连的边,一些点割掉与n-1相连的边 我们去观察每个点与0相连和与n-1相连的两条边权值,容易发现…
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant very much loves sums on intervals. This time he has a pair of integers l and r (l ≤ r…
春训团队赛第四场 ID A B C D E F G H I J K L M AC O O O O O O O O O 补题 ? ? O O 传送门 题目链接(CF Gym102021) 题解链接(pdf) 代码 & 简易题解 [A]:LCA 给定一个格状迷宫,保证任意点均可达,且任意两格点间有且仅有一条简单路径. 给定一组移动序列,求按照这个序列走的累计路程. 按照题意对图预处理,得到一棵树,对于每对询问求 \(\text{LCA}\) 的同时求距离,累加即为答案. 一开始 \(\text{RE…
打表出奇迹!表打出来发现了神奇的规律: 1 1 2 2 3 4 4 4 5 6 6 7 8 8 8 8 9 10 10 11 12 12 12 13 14 14 15 16 16 16 16 16... 嗯嗯嗯?没有规律?我们把每个数出现的次数列出来: 2 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 然后惊觉表中的数字是连续的,每个都至少有一个,而分解因数中有只要2的幂,有一个就会加一,比如8是2.4.8的倍数,在1的基础上会多三个.(1和2除外) 所以对于一个位置$x$,我们可…
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the…
考场上几乎是一看就看出来轮廓线叻...可是调了两个小时打死也过不了手出样例!std发下来一对,特判对的啊,转移对的啊,$dp$数组竟然没有取max!!! 某位考生当场死亡. 结果下午又请了诸位dalao来看为什么剩下wa两个点!结果数组开小. 某位考生再次死亡. #include<bits/stdc++.h> #define RG register using namespace std; ][(<<)+], cnt[(<<)+]; ][];////////不开够影响很…
感受到了生活的艰辛QAQ...这才是真正的爆锤啊...(因为t1t3还没有理解所以只能贴t2叻QAQ 区间DP...爆哭把题理解错了,以为随着拿的东西越来越多,断点也会越来越多,出现可以选很多的情况QAQ,然而是不会的,自始至终只会有一个断点,哥哥和妹妹取都只有两个方向,而妹妹还是强制选择的QAQ. 所以把环展开就是一个区间DP叻,枚举长度(长度作为层数).区间,因为是从长度小的转移到长度多的,区间根据长度的奇偶性可以判断当前该谁拿,如果是妹妹,就在两端取大的更新区间(不加dp值),如果是哥哥就…