链接:https://ac.nowcoder.com/acm/contest/330/E
来源:牛客网

题目描述

精通程序设计的 Applese 叕写了一个游戏。

在这个游戏中,有一个 n 行 m 列的方阵。现在它要为这个方阵涂上黑白两种颜色。规定左右相邻两格的颜色不能相同。请你帮它统计一下有多少种涂色的方法。由于答案很大,你需要将答案对 109+7109+7 取模。

输入描述:

仅一行两个正整数 n, m,表示方阵的大小。

输出描述:

输出一个正整数,表示方案数对 109+7109+7 取模。
示例1

输入

复制

1 1

输出

复制

2
示例2

输入

2 2

输出

4

备注:

1≤n,m≤10100000

欧拉降幂公式:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<math.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll p=1e9+;
const ll x=p-; char a[],b[];
int c[]; ll power(ll a,ll b)
{
ll ans=;
while(b)
{
if(b%)
ans=ans*a%p;
a=a*a%p;
b=b/;
}
return ans%p;
}
int main()
{
scanf("%s%s",a,b);
int len=strlen(a);
for(int i=;i<len;i++)
c[i]=a[i]-'';
ll res=;
for(int i=;i<len;i++)
{
res=(res*+c[i])%x;
}
printf("%lld",power(,res+x));
return ;
}
//欧拉降幂公式:在%m时,指数k = k%oula(m)+oula(m)

Applese涂颜色-欧拉降幂公式的更多相关文章

  1. bzoj3884: 上帝与集合的正确用法 欧拉降幂公式

    欧拉降幂公式:http://blog.csdn.net/acdreamers/article/details/8236942 糖教题解处:http://blog.csdn.net/skywalkert ...

  2. D - Power Tower欧拉降幂公式

    题意:给你一个数组a,q次查询,每次l,r,要求 \(a_{l}^{a_{l+1}}^{a_{l+2}}...{a_r}\) 题解:由欧拉降幂可知,最多log次eu(m)肯定变1,那么直接暴力即可,还 ...

  3. HDU4704(SummerTrainingDay04-A 欧拉降幂公式)

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submi ...

  4. 2018牛客网暑期ACM多校训练营(第四场) A - Ternary String - [欧拉降幂公式][扩展欧拉定理]

    题目链接:https://www.nowcoder.com/acm/contest/142/A 题目描述 A ternary string is a sequence of digits, where ...

  5. 牛客OI测试赛 F 子序列 组合数学 欧拉降幂公式模板

    链接:https://www.nowcoder.com/acm/contest/181/F来源:牛客网 题目描述 给出一个长度为n的序列,你需要计算出所有长度为k的子序列中,除最大最小数之外所有数的乘 ...

  6. 欧拉降幂公式 Super A^B mod C

    Description Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=100000 ...

  7. HDU4704:Sum(欧拉降幂公式)

    Input 2 Output 2 Sample Input 2 由公式,ans=2^(N-1)%Mod=2^((N-1)%(Mod-1)+(Mod-1)) %Mod. 注意:降幂的之后再加一个Mod- ...

  8. FZU1759(SummerTrainingDay04-B 欧拉降幂公式)

    Problem 1759 Super A^B mod C Accept: 1056    Submit: 3444Time Limit: 1000 mSec    Memory Limit : 327 ...

  9. TOJ 3151: H1N1's Problem(欧拉降幂)

    传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3151 时间限制(普通/Java): ...

随机推荐

  1. jquery鼠标放上去显示悬浮层即弹出定位的div层

    <div><a id="a1" onmouseover="javascript:show('a1','div1');" onmouseout= ...

  2. Win10还原被Windows Defender隔离的文件

    Win10最新版本的Windows Defender隔离/删除的文件没有还原的选项,导致很多破解文件或是注册机直接隔离,到威胁历史记录中去却无法恢复.经过各个尝试,到微软官方论坛中也尝试了很多方法,后 ...

  3. angular的常见问题

    ng-if 跟 ng-show/hide 的区别有哪些? 第一点区别是,ng-if 在后面表达式为 true 的时候才创建这个 dom 节点,ng-show 是初始时就创建了,用 display:bl ...

  4. LeetCode 4. Median of Two Sorted Arrays & 归并排序

    Median of Two Sorted Arrays 搜索时间复杂度的时候,看到归并排序比较适合这个题目.中位数直接取即可,所以重点是排序. 再来看看治阶段,我们需要将两个已经有序的子序列合并成一个 ...

  5. 安装python的jupyter notebook工具

    jupyter notebook是一个通过网页运行python的工具 支持分段的python运行,并能直观的查看结果 支持多python环境运行,需要加装(conda) 安装步骤 1.安装python ...

  6. 使用docker生成centos7系统

    因为缺乏系统,所以使用docker镜像模拟生成多个系统,用于练习集群的安装. 查看已有镜像 docker images 下载镜像: docker pull centos: docker pull  镜 ...

  7. spring mvc 异常处理

    一般实现业务的时候避免不了会抛一些自定义异常 抛给controller进行最终处理.如果业务上比较复杂.频繁的在try catch操作. 时间一长,代码维护性,可读性自然而然就上来了. 然后,spri ...

  8. 《算法》第六章部分程序 part 1

    ▶ 书中第六章部分程序,包括在加上自己补充的代码,粒子碰撞系统及用到的粒子类 ● 粒子系统 package package01; import java.awt.Color; import edu.p ...

  9. 16. js方法传多个参数的实例

    field : 'operate',width : fixWidth(1/6),title : '操作',align : 'center',formatter : function(id,rowDat ...

  10. PHP AES加密解密。

    <?php namespace app\models; class AES{ public $key; //构造函数,用密钥初始化 function Prpcrypt( $k ) { $this ...