随笔分类 - 数学---FFT/NTT
摘要:(由于先看的最后一题,然后又一直WA,导致这场有点爆炸,我背锅。 A .Fancy Antiques 题意: 选择最多k个商店,买n个物品,每个物品分别对应两个店售卖,求最小花费是多少。n<100,k=m<=40; 思路:搜索。。。。开始以为是个费用流,然后没法限制。加N多减枝,然后.... B.
阅读全文
摘要:A .Little Pony and Expected Maximum pro:给定M,N,表示一个M面的骰子,甩N次,问出现的最大的数的期望。 sol:容斥,f(i)表示最大数<=i的期望,那么最大数=x的期望就是f(x)-f(x-1); B .Little Pony and Harmony Ch
阅读全文
摘要:All bus tickets in Berland have their numbers. A number consists of n digits (n is even). Only k decimal digits d1,d2,…,dk can be used to form ticket
阅读全文
摘要:Description 刚开始你有一个数字0,每一秒钟你会随机选择一个[0,2^n-1]的数字,与你手上的数字进行或(c++,c的|,pascal 的or)操作。选择数字i的概率是p[i]。保证0<=p[i]<=1,Σp[i]=1问期望多少秒后,你手上的数字变成2^n-1。 刚开始你有一个数字0,每
阅读全文
摘要:一个包含四个点的完全图,可以在任意节点出发,可以在任意节点结束,给出每个点被经过的次数,求有多少种合法的遍历序列。如果两个序列至少有一位是不同的,则认为它们不相同。 Input Sample Output 题意:给a个A,b个B,c个C,d个D,求有少种排列,使得相邻的两个不同。 思路:用容斥来做,
阅读全文
摘要:A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the
阅读全文
摘要:JRY wants to drag racing along a long road. There are nn sections on the road, the ii-th section has a non-negative integer length sisi. JRY will choo
阅读全文
摘要:Perhaps the sea‘s definition of a shell is the pearl. However, in my view, a shell necklace with n beautiful shells contains the most sincere feeling
阅读全文
摘要:Nikita likes tasks on order statistics, for example, he can easily find the kk-th number in increasing order on a segment of an array. But now Nikita
阅读全文
摘要:占位
阅读全文
摘要:很久很久以前,在你刚刚学习字符串匹配的时候,有两个仅包含小写字母的字符串A和B,其中A串长度为m,B串长度为n。可当你现在再次碰到这两个串时,这两个串已经老化了,每个串都有不同程度的残缺。 你想对这两个串重新进行匹配,其中A为模板串,那么现在问题来了,请回答,对于B的每一个位置i,从这个位置开始连续
阅读全文
摘要:把每一位看成ai*10^i,然后就是两个多项式相乘。利用FFT,把复杂度降到O(nlogn)。
阅读全文
摘要:FFT在用于解决多项式乘法A*B(A和B为多项式,形如a0+a1*x^1+a2*x^2....)的时候,通俗地解释就是: 原理:先根据各自的系数各自转化为对应的向量(O(nlogn)),然后向量相乘(O(n)),最后再还原得到相乘后的系数(O(nlogn))。 手段:利用了虚数,使得可以分治来快速求
阅读全文
摘要:You're given a sequence s of N distinct integers.Consider all the possible sums of three integers from the sequence at three different indicies.For ea
阅读全文