POJ3734 Block母函数入门
一段长度为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母函数入门的更多相关文章
- 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 ...
- HDU1028Ignatius and the Princess III母函数入门
这个题也能够用递归加记忆化搜索来A,只是因为这题比較简单,所以用来做母函数的入门题比較合适 以展开后的x4为例,其系数为4,即4拆分成1.2.3之和的拆分数为4: 即 :4=1+1+1+1=1+1+2 ...
- 母函数入门笔记(施工中…
定义:对于一个数列,它的母函数(即生成函数)为 为了对这个准确求值,我们设 举一个简单的例子 例1 对于数列 他的生成函数为 ,那么应用一下等比数列求和公式 这里由于 所以当时 那么 例 ...
- 母函数(Generation Function) 入门 + 模板
转自:母函数 入门 + 模板 感谢 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的 ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu1521 指数型母函数
排列组合 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- webpack入门文档教程
.octicon{margin-right:2px}a.tabnav-extra:hover{color:#4078c0;text-decoration:none}.tabnav-btn{margin ...
- HDU 1028 HDU 1398 (母函数)
题意:输入一个n 给出其所有组合数 如: 4 = 4; 4 = 3 + 1; 4 = 2 + 2; 4 = 2 + 1 + 1; 4 = 1 + 1 + 1 + 1; 重复不算 母函数入门题 ...
- HDU - 1085 母函数
年轻人的第一道母函数入门题 #include<bits/stdc++.h> using namespace std; const int maxn = 1000+2000+5000+1; ...
随机推荐
- Linux( Ubantu ) 的简单使用
1.Linux常用的快捷键 Ctrl + Alt+ T --打开终端 Ctrl + Shift + C --复制 Ctrl + Shift + V --粘贴 Ctrl + Shift + A --光标 ...
- Bind+DLZ构建企业智能DNS/DNS
Bind+DLZ构建企业智能DNS 目录:一.简介二.服务规划三.安装BIND及基本环境四.配置Bind-View-DLZ-MYSQL五.添加相关记录并进行测试六.配置从DNS七.补充 一.简介: ...
- Http中的三种请求处理模式(MPM)的区别
MPM---包括基于事件/异步,线程化和预分叉 MPM(multi-processing module)多种请求处理模式,分为三种工作模式: prefork worker event prefork- ...
- Codeforces 852F String Compression
题目 OvO http://codeforces.com/contest/825/problem/F 题解 KMP+DP 十分优雅地利用了KMP的fail数组 fail[k]表示第k个后缀的的fail ...
- MySQL下载与安装、解决报错
MySQL下载与安装 一.下载 1.登录Mysql官网:https://www.mysql.com/ 2.点击下载Mysql社区版本 3.点击下载 4.点击下载Mysql社区服务 5.下载地址: 历史 ...
- JavaScript基础之变量的自增与自减
一.自增(++) ⑴什么是自增? 通过自增运算符可以使变量在自身的基础上加一: 对于一个变量自增以后,原变量的值会立即自增一: 示例: <!DOCTYPE html> <html l ...
- js中Array的sort方法
Array.sort方法里需要传入一个参数,是一个function, 如果想要升序排序,就传入这样的一个function: function sortFunction(a,b){ return a-b ...
- CSS的水平居中和垂直居中
水平居中如果不太熟悉盒子模型的话属实不太好理解,其实就是控制其他属性来让border之内的内容被控制在父容器中间就行了,最经典的就是使用{margin: 0 auto}了,控制其上下外边框为0,左右 ...
- CSS3选择器:nth-child和:nth-of-type的差异
p:nth-child(2)表示这个元素要是p标签,且是第二个子元素,是两个必须满足的条件. <section> <div>我是一个普通的div标签</div> & ...
- Linux网络编程二、tcp连接API
一.服务端 1.创建套接字: int socket(int domain, int type, int protocol); domain:指定协议族,通常选用AF_INET. type:指定sock ...