Shell Necklace
Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1587 Accepted Submission(s): 721
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 the shell necklace is a sequence of shells (not a chain end to end). Considering i continuous shells in the shell necklace, I know that there exist different schemes to decorate the i shells together with one declaration of love.
I want to decorate all the shells with some declarations of love and decorate each shell just one time. As a problem, I want to know the total number of schemes.
Input
Output
For each test case, print one line containing the total number of schemes module
313![]()
(Three hundred and thirteen implies the march 13th, a special and purposeful day).
Sample Input
Sample Output
14 54
Hint
![HDU 5730: Shell Necklace 分治FFT_第1张图片](http://img.e-com-net.com/image/info8/61edfe5eea1e4db59b3fa65e5fc9913f.jpg)
For the first test case in Sample Input, the Figure 1 provides all schemes about it. The total number of schemes is 1 + 3 + 3 + 7 = 14.
Author
HIT
Source
2016 Multi-University Training Contest 1
递推式很显然
![](http://img.e-com-net.com/image/info8/c3d2bf7f47694ad2b88e2c196cc4e2f7.jpg)
然而这个东西虽然是卷积 但显然不能直接FFT
所以呢 分治FFT/NTT !
具体来讲就是
每次处理区间 [l,r]
先处理 [l,mid]
对于 [l,mid] 已求出真值 处理其对 [mid+1,r] 取值的影响
之后再处理 [mid+1,r]
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include