题目链接 考虑枚举好点的集合.此时要考虑的问题是如何填入\(1\sim n\)这些数使得恰好我们枚举到的这些点是好点,即:求出有多少种合法的填数方案. \(1\)号点一定是好点.那么除\(1\)号点外每个点的祖先中必有至少一个好点.定义\(u\)的祖先中离\(u\)最近的好点,为\(u\)的祖先好点\((2\leq u\leq n)\). 对除\(1\)外的每个点: 如果它是好点,我们就从它的祖先好点向它连一条边.(称为"第一类边") 如果它是不是好点,就从它向它的祖先好点连一条边.(…
题面传送门 一道非常不错的 FWT+插值的题 %%%%%%%%%%%% 还是那句话,反正非六校的看不到题对吧((( 方便起见在下文中设 \(n=2^d\). 首先很明显的一点是这题涉及两个维度:异或和与选出的元素的个数.因此考虑像子集卷积那样建立一个二元生成函数表示这个东西,具体来说我们定义一个幂级数 \(F\)​​ 形如 \(\sum\limits_{n\ge 0}\sum\limits_{m\ge 0}f_{n,m}x^ny^m\)​​,并定义两个幂级数 \(F,G\)​​ 的乘法得到的幂级…
由于 NFLSOJ 题面上啥也没有就把题意贴这儿了( 没事儿,反正是上赛季的题,你们非六校学生看了就看了,况且看了你们也没地方交就是了 题意: 给你一张 \(n\) 个点 \(m\) 条边的图 \(G=(V,E)\). 要求有多少张子图 \(G'=(V',E')\)​ 满足 \(G'\) 是连通二分图. \(n\le 20,m\le\dfrac{n(n-1)}{2}\) 答案对 \(998244353\) 取模. 输入样例 #1: 3 3 1 2 1 3 2 3 输出样例 #1: 9 众所周知,…
题目链接 我们称"简要题意"给出的三个要求分别为"条件1","条件2","条件3". 条件3长得比较丑,考虑转化一下.把不等式两边同时开\(ij\)次根,得到:\(\sqrt[i]{x_i}<\sqrt[j]{x_j+1}\).这样左边只和\(i\)有关,右边只和\(j\)有关.于是条件3就转化为了\((\max_{i=1}^{n}\sqrt[i]{x_i})<(\min_{i=1}^{n}\sqrt[i]{x_i…
题目链接 以下把值域(题面里的\(lim\))记做\(m\). 考虑求\(k\)的答案.考虑每个位置对答案的贡献,枚举位置\(i\),再枚举\(a[i]\)的值\(x\).设: \[ F(k)=\sum_{i=k+1}^{n}m^{i-k-1}m^{n-i}{i-1\choose k}\sum_{x=1}^{m}(x-1)^k \] 如果对着式子打一个\(O(n^2m)\)的暴力,就会发现这个\(F(k)\)并不是答案,它比答案大.它其实是\(i\)前面至少有\(k\)个数的方案数.而一个序列,…
pid=5358">HDU 5358 题意: 求∑​i=1​n​​∑​j=i​n​​(⌊log​2​​S(i,j)⌋+1)∗(i+j). 思路: S(i,j) < 10^10 < 2^34.所以log2(S)+1的值仅仅可能在1~35之间.因为log变化缓慢的函数特性,我们能够S(i,n)分作多个同样log值的区间来计算,用pos[i][j]预处理记录每一个以i为起点,log(s)值为j的区间的右边界.就可以优化至nlogn的复杂度. 主要是写起来比較难一些,一些细节比較纠结,…
Is Derek lying? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 612    Accepted Submission(s): 353 Problem Description Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.Thi…
题目链接 Problem Description Function Fx,ysatisfies: For given integers N and M,calculate Fm,1 modulo 1e9+7. Input There is one integer T in the first line. The next T lines,each line includes two integers N and M . 1<=T<=10000,1<=N,M<2^63. Output…
这题起初没读懂题意,悲剧啊,然后看了题解写完就AC了 题意是给一个N,然后给N+1个整数 接着给N个操作符(只有三种操作  即  或 ,与 ,和异或 |   &  ^ )这样依次把操作符插入整数之间就可以得到一个表达式 接着给出 N 给浮点数(在0~1之间表示概率 )表示的是 操作符和他右边的整数丢失的概率. 例如下面这组数据 1 1 2 & 0.5 整数与操作符间可以组成一个表达式即 1&2 但是由于某些原因表达式的操作符和他操作的右边的 那个数有一定的概率会丢失这组数据就是 &…
点击打开链接 我就不说官方题解有多坑了 V图那么高端的玩意儿 被精度坑粗翔了 AC前 AC后 简直不敢相信 只能怪自己没注意题目For the distance d1 and d2, if fabs(d1-d2)<1e-7, we think d1 == d2 有空再补充V图的做法吧..本人也是第一次接触V图 //大白p263 #include <cmath> #include <cstdio> #include <cstring> #include <se…
题目链接 Problem Description Giving two strings and you should judge if they are matched. The first string contains lowercase letters and uppercase letters. The second string contains lowercase letters, uppercase letters, and special symbols: "." an…
题目链接 Problem Description There is a nonnegative integer sequence a1...n of length n. HazelFan wants to do a type of transformation called prefix-XOR, which means a1...n changes into b1...n, where bi equals to the XOR value of a1,...,ai. He will repea…
题目链接 Problem Description The school set up three elective courses, assuming that these courses are A, B, C. N classes of students enrolled in these courses. Now the school wants to count the number of students who enrolled in at least one course in e…
题目链接 Problem Description In the mathematical discipline of graph theory, a bipartite graph is a graph whose vertices can be divided into two disjoint sets U and V (that is, U and V are each independent sets) such that every edge connects a vertex in…
题目链接 Problem Description Have you ever seen the wave? It's a wonderful view of nature. Little Q is attracted to such wonderful thing, he even likes everything that looks like wave. Formally, he defines a sequence a1,a2,...,an as ''wavel'' if and only…
题目链接 Problem Description In mathematics, the function d(n) denotes the number of divisors of positive integer n. For example, d(12)=6 because 1,2,3,4,6,12 are all 12's divisors. In this problem, given l,r and k, your task is to calculate the followin…
题目链接 Problem Description In ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the following way. First let's ignore all the problems the team didn't pass, assume the team passed X problems during the contest, and submitted Y times for t…
Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description Kazari remembered that she had an expression s…
构造题: 比赛的时候只想到:前面一样的数,后面 是类似1,2,3,4,5,6....t这 既是:t+1,t+1...,1,2,3,...t t+1的数目 可能 很多, 题解时YY出一个N 然后对N  判断. seg{Li*(Li-1)} = n*n+n-2*k=d; 每次跑sqrt(n)找到 最近的 d ,D_new=d-Li*(Li-1); 这样一定能解的:d 一定是偶数,Li*(Li-1)也一定是偶数,2*1=2; 还有seg(Li)=n; 当Li=1是 Li*Li-Li=0; 加入一些1就…
pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法.求出以第i个点为中心的回文串长度.记录到数组p中 要满足题目所要求的内容.须要使得两个相邻的回文串,共享中间的一部分,也就是说.左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也…
Description ?? is practicing his program skill, and now he is given a string, he has to calculate the total number of its distinct substrings. But ?? thinks that is too easy, he wants to make this problem more interesting. ?? likes a character X very…
本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> using namespace std; char s[3][30]; int player…
Bubble Sort Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 224    Accepted Submission(s): 147 Problem Description P is a permutation of the integers from 1 to N(index starting from 1). Here is…
题目连接:Click here 题意:在一个[L,R]内找到最大的gcd(f[i],f[j])其中L<=i<j<=R,f[x]表示i分解质因数后因子的种类数.eg:f[10]=2(10=2*5),f[12]=2(12=2*2*3). 分析:很容易想到先将f[x]求出来,这里x最大1e6,要在常数时间内求出f[x].并且稍加分析就知道1<=f[x]<=7,可以用一个dp[i][j]表示从f[1]到f[i]有多少个j.这样就可以在常数时间内预处理出来,后面在O(1)的时间内就可以…
题目连接:戳ME #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; int n, k; int par[M]; int sum[M]; void find(int x) { if( par[x]!=x ) { sum[par[x]]++; find(par[x]); } else return; } int main() { while( ~scanf(&quo…
描述 LT最近一直在无限循环薛之谦的歌,简直都中毒了!可是呢…他的歌LT还是不会唱(其实不止他的歌LT不会唱,所有人的歌LT都不会唱…因为LT是标准的音痴)可是LT又很喜欢唱歌(所以LT不仅是音痴还是音痴)…没错,这对于LT的室友来说简直是噩梦… 现在呢,LT有N次操作,每次操作只会有两种可能: I a: 表示着LT使用唱歌软件唱歌得到的分数. Q k: 表示着LT想知道自己得到的第k小的分数是多少.(如果没有第k小,输出-1)   输入 有多组输入(不超过20组),每组输入的第一行是一个N,表…
描述  有N个人,N个活动, 每个人只会对2个或者3个活动感兴趣,  每个活动也只有两个人或者两个活动对它兴趣,每个人参加一个  感兴趣的活动需要一天 ,且当天该活动被参加时,其他的人不能参加  如果每个人都参加完自己有兴趣的活动,应当怎样安排使得所用总天数时间最短 2<= N <=1000, 1<=m<=1000;   输入 一个数T 表示T 组数据每组一个N表示人数,编号1 -- N , 一个数 m ,接下来m 行每个两个数x,y, 表示第 x 个人对第y个活动感兴趣 输出 每…
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes:…
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2. LsF wants to make some trouble. While zk is sleeping, Ls…
题目链接 Problem Description The Eternal Fleet was built many centuries ago before the time of Valkorion by an unknown race on the planet of Iokath. The fate of the Fleet's builders is unknown but their legacy would live on. Its first known action was in…