Input

2

Output

2

Sample Input

2

由公式,ans=2^(N-1)%Mod=2^((N-1)%(Mod-1)+(Mod-1)) %Mod。

注意:降幂的之后再加一个Mod-1保险,避免为负,比如此题出入1000000006时,就出问题了。

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
const int Mod=1e9+;
char c[];
ll ans,sum,g;
ll qpow(ll a,ll x){
ll res=;
while(x){
if(x&) res=res*a%Mod;
x>>=;
a=a*a%Mod;
}
return res;
}
int main()
{
int L,i,j;
while(~scanf("%s",c+)){
L=strlen(c+);
sum=;g=;
for(i=L;i>=;i--){
sum=(sum+(c[i]-'')*g)%(Mod-);
g=g*%(Mod-);
}
ans=qpow(,sum+Mod-);
printf("%lld\n",ans);
}
return ;
}

最新文章

  1. Shell入门教程:流程控制(6)while 循环
  2. [NOIP2015] 提高组 洛谷P2678 跳石头
  3. 通过setDB2Client*来方便的使用TRACE调优jdbc程序
  4. 冲刺阶段 day2
  5. MySQL Server 5.7解压版缺少文件无法启动
  6. poj 3278 Catch That Cow (广搜,简单)
  7. RDD.scala(源码)
  8. HDU 5416 CRB and Tree
  9. Nodejs in Visual Studio Code 11.前端工程优化
  10. java 获取特定天数的时间戳
  11. [Swust OJ 1139]--Coin-row problem
  12. 换行符以及for循环的优化
  13. ExtJS的4.1新特性简要介绍
  14. 关于WebService、WebApi的跨域问题
  15. CVE-2017-8464复现 (远程快捷方式漏洞)
  16. 接口测试工具-tamper data
  17. go标准库的学习-net/url
  18. Http请求帮助类
  19. XP、Windows7下自动关机vbs脚本,使用windows计划任务+vbs脚本在XP、Windows7下实现定时自动关机
  20. Python __str__函数

热门文章

  1. 1010. Radix (25)(出错较多待改进)
  2. VIM键盘图
  3. AI Gossip
  4. 在Ignite中使用线性回归算法
  5. 洛谷P1276 校门外的树(增强版)未完工
  6. hdu 1501 基本搜索深搜
  7. 【BZOJ1061】志愿者招募(单纯形,对偶性)
  8. linux 常见名词及命令(二)
  9. IText 生成pdf,处理table cell列跨页缺失的问题
  10. 2017CodeM初赛B场