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; ...
随机推荐
- tomcat不能处理图形
https://blog.csdn.net/yfx000/article/details/86591945 不让java寻找linux图形界面即可,在java启动时加选项java -Djava.awt ...
- 小程序是单页面应用,有一个页面执行wx.showLoading(),其他页面也会显示
my.js onLoad: function (options) { setTimeout(res=>{ wx.showLoading({ title: '10s后出现', }) }, ) }, ...
- gRPC应用实践
What is RPC? Remote Procedure Call is a high-level model for client-server communication. Assume the ...
- 5天noip训练心得
day1 100+95+0=195 T1 二分答案,并查集,很像noip2017 day2 T1 T2 缩环,然后数据结构维护求答案,貌似也是原题 T3 树形dp,比赛上没有做出来, day2 90+ ...
- POJ 2142 - The Balance [ 扩展欧几里得 ]
题意: 给定 a b n找到满足ax+by=n 的x,y 令|x|+|y|最小(等时令a|x|+b|y|最小) 分析: 算法一定是扩展欧几里得. 最小的时候一定是 x 是最小正值 或者 y 是最小正值 ...
- Python—数据类型之字典(Dict)
其它数据类型转成字典 arr1 = ['jack', 'rose', 'marry'] arr2 = [68, 85, 66] dict1 = dict(zip(arr1, arr2)) print( ...
- bzoj 4899 记忆的轮廓 题解(概率dp+决策单调性优化)
题目背景 四次死亡轮回后,昴终于到达了贤者之塔,当代贤者夏乌拉一见到昴就上前抱住了昴“师傅!你终于回来了!你有着和师傅一样的魔女的余香,肯定是师傅”.众所周知,大贤者是嫉妒魔女沙提拉的老公,400年前 ...
- K 短路
这种东西到现在才学-- 考虑 \(T\) 为根的最短路树,一条路径一定是树上边和非树边交错. 我们只管非树边,对于一条路径,非树边构成一个序列 \(L\),相邻两条路径 \(\left(u_1,v_1 ...
- (Java多线程系列二)线程间同步
Java多线程间同步 1.什么是线程安全 通过一个案例了解线程安全 案例:需求现在有100张火车票,有两个窗口同时抢火车票,请使用多线程模拟抢票效果. 先来看一个线程不安全的例子 class Sell ...
- Into Blocks (easy version)
G1 - Into Blocks (easy version) 参考:Codeforces Round #584 - Dasha Code Championship - Elimination Rou ...