• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

HDU6146PokémonGODP,计数

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6146

题意:~

解法:原题。。http://blog.csdn.net/y990041769/article/details/21243895

 

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 10010;
LL a[maxn], b[maxn];
const LL mod = 1e9+7;
int n;

int main()
{
    int T;
    scanf("%d", &T);
    while(T--){
        scanf("%d", &n);
        b[1]=1LL;
        for(int i=2; i<=n; i++) b[i]=(b[i-1]*2LL%mod)%mod;
        a[1]=1LL;
        a[2]=6LL;
        for(int i=3; i<=n; i++){
            a[i]=(2LL*a[i-1]+1LL*b[i]+4LL*a[i-2])%mod;
        }
        long long sum = 4*a[n];
        for(int i=2; i<n; i++){
            sum += ((8LL*b[n-i]*a[i-1])%mod+(8LL*a[n-i]*b[i-1])%mod)%mod;
            sum %= mod;
        }
        if(n==1) sum=2;
        printf("%lld\n", sum);
    }
    return 0;
}

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Go-Mega Web开发教程 01 - Hello World发布时间:2022-07-10
下一篇:
go中byte类型发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap