hdu5730 Shell Necklace】的更多相关文章

题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5730 Description 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 for my best lover Arrietty, but…
重温了这道cdq+FFT 讲白了就是不断对 dp[l~mid] 和 sh[1~r] 进行fft 得到 dp[mid+1~r] #include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e5+5; const int MOD = 313; int N; int sh[MAXN], dp[MAXN]; int ans; /****************FFT*************/…
题目 简述: 有一段长度为n的贝壳,将其划分为若干段,给出划分为每种长度的方案数,问有多少种划分方案 题解 设\(f[i]\)表示长度为\(i\)时的方案数 不难得dp方程: \[f[i] = \sum\limits_{j=0}^{i} a[j] * f[i - j]\] 考虑转移 直接转移是\(O(n^2)\)的 如何优化? 容易发现这个转移方程非常特别,是一个卷积的形式 考虑fft 分治fft 分治fft解决的就是这样一个转移方程的快速计算的问题 \[f[i] = \sum\limits_{…
HDU5730 Shell Necklace 题目大意 已知连续i(1<=i<=n)个贝壳组合成一段项链的方案数a[i],求组合成包含n个贝壳的项链的总方案数. Solution cdq分治 我们考虑最朴素的\(dp​\). 设\(f_i​\)表示包含\(i​\)个贝壳的方案数,很容易写出转移方程: \(f_i=\sum_{j=1}^if_{i-j}×a_j\) 发现这个dp方程直接转移是\(O(n^2)\)的,要优化一下.... 这个式子不就是分治FFT的式子? 直接cdq不就好了吗? 多项…
[HDU5730]Shell Necklace(多项式运算,分治FFT) 题面 Vjudge 翻译: 有一个长度为\(n\)的序列 已知给连续的长度为\(i\)的序列装饰的方案数为\(a[i]\) 求将\(n\)个位置全部装饰的总方案数. 答案\(mod\ 313\) 题解 很明显,是要求: \(f[n]=\sum_{i=0}^na[i]\times f[n-i],f[0]=0\) 卷积的形式啊.. 然后就可以开始搞了 忍不住的方法一 好明显啊,把生成函数\(F,A\)给搞出来 然后就有\(F*…
Shell Necklace Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 534    Accepted Submission(s): 227 Problem Description Perhaps the sea‘s definition of a shell is the pearl. However, in my view,…
hdu 5730 Shell Necklace 题意:求递推式\(f_n = \sum_{i=1}^n a_i f_{n-i}\),模313 多么优秀的模板题 可以用分治fft,也可以多项式求逆 分治fft 注意过程中把r-l+1当做次数界就可以了,因为其中一个向量是[l,mid],我们只需要[mid+1,r]的结果. 多项式求逆 变成了 \[ A(x) = \frac{f_0}{1-B(x)} \] 的形式 要用拆系数fft,直接把之前的代码复制上就可以啦 #include <iostream…
Description 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 for my best lover Arrietty, but even that is not enough. Suppose the shell necklace is a…
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 for my best lover Arrietty, but even that is not enough. Suppose the shell necklace is a sequence of…
Shell Necklace Problem Description 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 for my best lover Arrietty, but even that is not enough. Suppose…