1002

思路:

  打表找规律:

    dp[i]=dp[i-1]*3-dp[i-2]+2;

  套个高精就a了;

代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; struct NumberType {
int len; int ai[]; void print()
{
for(int i=len;i>;i--) putchar(ai[i]+'');
} void mul(NumberType a)
{
len=a.len;
for(int i=a.len;i>;i--) ai[i]=a.ai[i]*;
for(int i=;i<=a.len;i++) ai[i+]+=ai[i]/,ai[i]%=;
while(ai[len+]) len++;
} void minus(NumberType a)
{
for(int i=;i<=len;i++)
{
if(ai[i]<a.ai[i]) ai[i]+=,ai[i+]--;
ai[i]-=a.ai[i];
}
while(!ai[len]) len--;
} void updata()
{
ai[]+=;
for(int i=;i<=len;i++)
{
if(ai[i]>) ai[i]-=,ai[i+]+=;
else break;
}
while(ai[len+]) len++;
}
};
struct NumberType dp[]; int n; int main()
{
scanf("%d",&n);
dp[].len=,dp[].len=,dp[].ai[]=;
for(int i=;i<=n;i++) dp[i].mul(dp[i-]),dp[i].minus(dp[i-]),dp[i].updata();
dp[n].print();
return ;
}

AC日记——[FJOI2007]轮状病毒 bzoj 1002的更多相关文章

  1. AC日记——[Hnoi2017]影魔 bzoj 4826

    4826 思路: 主席树矩阵加减+单调栈预处理: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 200005 ...

  2. AC日记——[LNOI2014]LCA bzoj 3626

    3626 思路: 离线操作+树剖: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #defin ...

  3. AC日记——[ZJOI2012]网络 bzoj 2816

    2816 思路: 多个LCT: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 10005 #define l ...

  4. AC日记——[SCOI2009]游戏 bzoj 1025

    [SCOI2009]游戏 思路: 和为n的几个数最小公倍数有多少种. dp即可: 代码: #include <bits/stdc++.h> using namespace std; #de ...

  5. AC日记——[HNOI2014]世界树 bzoj 3572

    3572 思路: 虚树+乱搞: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 300005 #define ...

  6. AC日记——NOI2016区间 bzoj 4653

    4653 思路: 线段树,指针滑动: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #def ...

  7. AC日记——Rmq Problem bzoj 3339

    3339 思路: 恶心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include ...

  8. AC日记——[HNOI2008]越狱 bzoj 1008

    1008 思路: 越狱情况=总情况-不越狱情况: 代码: #include <cstdio> #include <cstring> #include <iostream& ...

  9. AC日记——[Ahoi2013]作业 bzoj 3236

    3236 思路: 莫队+树状数组维护: 代码: #include <cmath> #include <cstdio> #include <cstring> #inc ...

随机推荐

  1. To Chromium之VS调试追踪

    启动的code: for(;;){...WaitForWork()}base.dll!base::MessagePumpForUI::DoRunLoop                         ...

  2. online community

    online community spectrum https://spectrum.chat/xgqfrms https://community.xgqfrms.xyz/ https://spect ...

  3. mysql类型与java类型对应异常场景

    MySQL的bigint unsigned类型,对应java的BigInteger类型,在基于mybatis框架时,如果我将bigint unsigned类型的字段的返回放在一个map的返回类型中时. ...

  4. 安装和配置hadoop集群步骤

    hadoop集群的安装步骤和配置 hadoop是由java语言编写的,首先我们肯定要在电脑中安装jdk,配置好jdk的环境,接下来就是安装hadoop集群的步骤了,在安装之前需要创建hadoop用户组 ...

  5. Js跑马灯效果 && 在Vue中使用

    DEMO: <!DOCTYPE html><html> <head> <title>滚动播报</title> <meta charse ...

  6. CSS3不遥远,几个特性你要知道

    CSS是众所周知且应用广泛的网站样式语言,在它的版本三(CSS3)计划中,新增了一些能够节省时间的特性.尽管只有当前最新了浏览器版本才能支持这些 效果,但了解它们还是必须且很有趣味性的.CSS3中的5 ...

  7. ubunut14.04 mentohust配置

      1.设置网卡eth0的IP地址和子网掩码 sudo ifconfig eth0 10.162.32.94 netmask 255.0.0.0 将IP地址改为:10.162.32.94,子网掩码改为 ...

  8. javascript中arguments的应用——不定项传参求和

    <script type="text/javascript"> window.onload=function(){ function sum(){ var result ...

  9. 25个常规方法优化你的jquery代码

    原文发布时间为:2011-06-06 -- 来源于本人的百度文章 [由搬家工具导入] http://www.tvidesign.co.uk/blog/improve-your-jquery-25-ex ...

  10. 【洛谷 P2480】 [SDOI2010]古代猪文(中国剩余定理,Lucas定理)

    题目链接 这题出的有点nb,PKU: Pig Kingdom University , NOIP: National Olympics in Informatic of Pigs... 题意:求\(G ...