题干:

David has a white board with 2 \times N2×N grids.He decides to paint some grids black with his brush.He always starts at the top left corner and ends at the bottom right corner, where grids should be black ultimately.

Each time he can move his brush up(), down(), left(), right(), left up(), left down(), right up(), right down () to the next grid.

For a grid visited before,the color is still black. Otherwise it changes from white to black.

David wants you to compute the number of different color schemes for a given board. Two color schemes are considered different if and only if the color of at least one corresponding position is different.

Input

One line including an integer n(0<n \le 10^9)n(0<n≤109)

Output

One line including an integer, which represent the answer \bmod 1000000007mod1000000007

样例输入1复制

2

样例输出1复制

4

样例解释1

样例输入2复制

3

样例输出2复制

12

样例解释2

题目大意:

本身是2*N的白色格子,你从左上角开始走到右下角,每次可以往八个方向走,问你可以踩出多少种本质不同的图案来。

解题报告

不难发现如果要走到后面,那么中间的任何一列都要被踩到。所以对于每一列,可以踩上 下 上下  这三种选择,在加上首尾两列的四种选择,所以答案就是  4*3^(n-2)。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
const ll mod = 1000000007;
ll n;
ll qpow(ll a,ll k) {ll res = 1;while(k) {if(k&1) res =(res*a)%mod;a=(a*a)%mod;k>>=1;}return res%mod;
}
int main()
{cin>>n;if(n == 1) printf("1\n");else if(n == 2) printf("4\n");else {ll ans = qpow(3,n-2);ans = ans*4;printf("%lld\n",ans%mod);}return 0 ;
}

【计蒜客 - 2019南昌邀请赛网络赛 - H】Coloring Game(找规律,思维dp)相关推荐

  1. 【计蒜客 - 2019南昌邀请赛网络赛 - I】Max answer(单调栈,RMQ)

    题干: Alice has a magic array. She suggests that the value of a interval is equal to the sum of the va ...

  2. 【计蒜客 - 2019南昌邀请赛网络赛 - M】Subsequence(字典树,dp预处理)

    题干: Give a string SS and NN string T_iTi​ , determine whether T_iTi​ is a subsequence of SS. If ti i ...

  3. 【计蒜客 - 2019南昌邀请赛网络赛 - K】MORE XOR(数学,找规律,打表)

    Given a sequence of nn numbers a_1, a_2, \cdots, a_na1​,a2​,⋯,an​ and three functions. Define a func ...

  4. 计蒜客 2019 蓝桥杯省赛 B 组模拟赛(一)

    D题:马的管辖 二进制枚举方案.判断该方案是否全部能被覆盖,将最优方案存下来并进行剪枝. #include<iostream> #include<cstring> #inclu ...

  5. 计蒜客 2019 蓝桥杯省赛 A 组模拟赛(一) B:炮台实验

    题目描述 蒜头君在玩一个战争模拟游戏,他有高度为 1,2,3,-,n 的炮台各一个,他需要把这 n 个炮台从左往右排成一行,并且炮口都朝向右边. 在这个游戏中,所有炮台发射的炮弹会摧毁前方所有高度比自 ...

  6. 计蒜客2019蓝桥杯省赛B组模拟赛(一)题目及解析

    蓝桥杯历年真题题目及题解目录汇总   A. 结果填空:钟表 题库链接 分值: 5 一天蒜头君 22:28:45 开始睡觉,06:24:26 醒来之后,蒜头君在想,今天我睡了多久? 请你告诉蒜头君睡了& ...

  7. 计蒜客2019蓝桥杯省赛 B 组模拟赛(一)轻重搭配|

    题解:这题一看就知道是贪心问题,但问题是怎么贪,直接暴力循环一遍,TLE.选错贪心思路,只能过一小部分数据,正确贪心思路:从前一半遍历,在后一半中找到比当前元素的两倍大的数 代码如下: #includ ...

  8. 2019南昌邀请赛网络赛

      A. PERFECT NUMBER PROBLEM 这题没什么要说的. #include<bits/stdc++.h>using namespace std;int main(){co ...

  9. 北京林业大学“计蒜客”杯程序设计竞赛 网络赛 马踏棋盘的问题

    //使用bfs #include<stdio.h> #include<iostream> #include<utility> #include<queue&g ...

最新文章

  1. 用拓扑排序检测有向图中是否有环
  2. 计算机里的音乐都是什么名字,PAPI
  3. Microsoft SQL Server 2005 Service Pack 2 已经可以下载
  4. 使用系统调用pipe建立一条管道线_使用Unixbench对服务器综合性能打分及测试结果...
  5. python爬取appstore的评论数据的步骤_python数据抓取分析
  6. GitGithub学习笔记
  7. 这行的压力还是比较大的
  8. CVE-2021-20226:详解 Linux 内核 IO_URING 子系统中的引用计数漏洞
  9. linux下安装apache + subversionSVN_Subversion
  10. [转]Android的Handler总结
  11. python 列表切片学习
  12. 帛书《要》篇“夫子老而好易”章
  13. js常用插件(八)之移动端滑动插件swiper,BScroll
  14. 轻松理解 java字节码
  15. 可编程串口接口芯片8251A
  16. 计算机考研数据库题库
  17. HttpClient:connection still allocated.解决方法
  18. HI3516A/Hi3516D H265流结构分析
  19. mybatis 通配符
  20. 五十二度系统维护光盘-驱动篇 1.16.2008

热门文章

  1. 高服从编纂器 VIM-操作篇(1)
  2. Dos下命令运行带有包名的Java类
  3. html字体变大自动换行,网页css中实现字符超出宽度自动换行和英语字符不断行的解决方法...
  4. Eclipse——恢复的默认窗口设置篇
  5. linux c 指针和内存分配内存,linux-C基础系列-内存管理(野指针).md
  6. selenium禁止弹窗_python:使用带有selenium的firefox时禁用下载弹出窗口
  7. 2个td合成一个td_18个月16个爆款,合成类玩法的下一个机会在哪?
  8. python cli_click python cli 开发包
  9. elementui树状菜单tree_vue.js+element-ui做出菜单树形结构
  10. 数字能查出笔迹吗_大家都知道文字可以做笔迹鉴定,我想问一下专家阿拉伯数字是否也可以做笔迹鉴定正确率高吗?...