一段长度为n的序列,你有红黄蓝绿四种颜色的砖块,一块砖长度为1,问你铺砖的方案数,其中红黄颜色之和必须为偶数。

#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; #define fi first
#define se second typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int maxn = 1000 + 5;
const int maxm = 100 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 10000 + 7;//19260817
const double pi = acos(-1.0); LL n, res; LL fpow(LL a, LL n){
LL ans = 1;
while(n){
if(n & 1) ans = ans * a % mod;
a = a * a % mod;
n >>= 1;
}
return ans;
} int main(){
int T;
scanf("%d", &T);
while(T--){
scanf("%lld", &n);
printf("%lld\n", (1LL * fpow(4, n - 1) % mod + fpow(2, n - 1) % mod) % mod);
}
return 0;
}
原文链接:https://blog.csdn.net/qq_43464645/article/details/95488472

  

POJ3734 Block母函数入门的更多相关文章

  1. hdu 1028 Ignatius and the Princess III(母函数入门+模板)

    Description "Well, it seems the first problem is too easy. I will let you know how foolish you ...

  2. HDU1028Ignatius and the Princess III母函数入门

    这个题也能够用递归加记忆化搜索来A,只是因为这题比較简单,所以用来做母函数的入门题比較合适 以展开后的x4为例,其系数为4,即4拆分成1.2.3之和的拆分数为4: 即 :4=1+1+1+1=1+1+2 ...

  3. 母函数入门笔记(施工中…

    定义:对于一个数列,它的母函数(即生成函数)为   为了对这个准确求值,我们设    举一个简单的例子 例1 对于数列 他的生成函数为 ,那么应用一下等比数列求和公式 这里由于 所以当时 那么   例 ...

  4. 母函数(Generation Function) 入门 + 模板

    转自:母函数 入门 + 模板  感谢 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的 ...

  5. hdu 1398 Square Coins (母函数)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  6. hdu1521 指数型母函数

    排列组合 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  7. webpack入门文档教程

    .octicon{margin-right:2px}a.tabnav-extra:hover{color:#4078c0;text-decoration:none}.tabnav-btn{margin ...

  8. HDU 1028 HDU 1398 (母函数)

    题意:输入一个n  给出其所有组合数 如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 重复不算 母函数入门题 ...

  9. HDU - 1085 母函数

    年轻人的第一道母函数入门题 #include<bits/stdc++.h> using namespace std; const int maxn = 1000+2000+5000+1; ...

随机推荐

  1. CentOS7 安装 RocketMQ 实践和小示例

    CentOS7 安装 RocketMQ 实践和小示例 1.通过 SSH 工具(比如 XShell)连接到 CentOS7 服务器上: 2.进入到 /usr/local 目录中: cd /usr/loc ...

  2. ESP8266常见问题汇总——转载自官网

    ESP8266 常见问题 本页面收集esp8266常见问题 概述 本文档主要介绍开发者在ESP8266开发中常见的一些问题. 这些问题主要包括以下几大类: 基本概念相关 ESP8266 相关 AiCl ...

  3. 深入理解python协程

    目录 概述 生成器变形 yield/send yield send yield from asyncio.coroutine和yield from async和await 概述 由于 cpu和 磁盘读 ...

  4. hdu 6065 RXD, tree and sequence

    题 OwO http://acm.hdu.edu.cn/showproblem.php?pid=6065 (2017 Multi-University Training Contest - Team ...

  5. (转载)了解Android 4.1,之三:黄油项目 —— 运作机理及新鲜玩意

    Welcome back to GTKA, everyone's favorite investigative series where we learn all about the newest v ...

  6. Plx9030通讯卡驱动开发与接口封装

    在学校的时候,曾经采用DDK+Driverstudio+VC6.0环境做过9054视频采集卡的驱动开发,回想起调试过程,记得最清楚的就是过无数次的计算机蓝屏重启....今天第一天来到新公司,老大就说你 ...

  7. Linux-expect脚本-编写一个expect脚本

    1.声明expect #!/usr/bin/expect -f 2.设置超时时间,获取参数 set ip [lindex $argv 0 ] //接收第一个参数,并设置IP set password ...

  8. C++的重载(overload)与重写(override)

    C++的重载(overload)与重写(override) 成员函数被重载的特征:(同一层级类中来实现)(1)相同的范围(在同一个类中):(2)函数名字相同:名称和返回类型相同(3)参数不同:(4)v ...

  9. Docker安装Redis及Warning解决方法

    虚拟机环境:VirtualBox 操作系统:CentOS 7 宿主机: Microsoft Windows 10 家庭中文版 Docker简介 Docker是一个轻量级容器技术.Docker直接运行在 ...

  10. Mysql 修改密码和设置远程连接

    [参考文章]:mysql修改root密码和设置权限 1. 修改密码 1.1 set password 登录mysql set password for 用户名@localhost = password ...