From 8165a376c1c81021a81adafb623917c9c6f22618 Mon Sep 17 00:00:00 2001 From: xingyou wu <3050128610@qq.com> Date: Tue, 1 Apr 2025 20:14:32 +0800 Subject: [PATCH] =?UTF-8?q?//=20lanqiao=202110=20(=E7=A7=AF=E6=9C=A8?= =?UTF-8?q?=E7=94=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 13lanqiao/test7.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 13lanqiao/test7.cpp diff --git a/13lanqiao/test7.cpp b/13lanqiao/test7.cpp new file mode 100644 index 0000000..817dac0 --- /dev/null +++ b/13lanqiao/test7.cpp @@ -0,0 +1,22 @@ +// lanqiao 2110 (积木画) +#include +using namespace std; +const int N = 10000010, MOD = 1e9 + 7; +int f[N]; +/* +递推法: +f1=1 f2=2 f3=5 f4=11 f5=24 f6=53 +f[n] = 2*f[n-1] + f[n-3] +*/ +int main(){ + int n; cin >> n; + f[1] = 1, f[2] = 2; f[3] = 5; + for(int i = 4; i <= n; i++){ + f[i] = (2*f[n-1] % MOD + f[i-3] % MOD) % MOD; + } + cout << f[n] << endl; + return 0; +} +/* test samples -> 5 +3 +*/ \ No newline at end of file