给出a,求递归式g(k)的初始条件g(0);

可以看出来g(a) = 1,从后往前推。写个模拟程序可以看出来其实g(0) = 2^a,那么就是一个简单地快速幂取模问题了。

#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll unsigned long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = b; i >= a; i--)
#define sfi(n) scanf("%d", &n)
#define pfi(n) printf("%d\n", n)
#define MAXN 4010
const int N = ;
#define mod 1000000007 ll modexp(ll a, ll b) //(a^b)%mod;
{
ll ret = ;
ll tmp = a;
while(b)
{
if(b&0x1) ret = ret*tmp%mod;
tmp = tmp*tmp%mod;
b >>= ;
}
return ret;
} int main()
{
ll a;
while(~scanf("%I64d", &a))
{
ll ans = modexp((ll), a);
printf("%I64d\n", ans);
}
return ;
}

【规律】Gym 100739L Many recursions的更多相关文章

  1. Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律

    Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...

  2. Codeforces Gym 100114 A. Hanoi tower 找规律

    A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...

  3. Gym 101981G - Pyramid - [打表找规律][2018-2019 ACM-ICPC Asia Nanjing Regional Contest Problem G]

    题目链接:http://codeforces.com/gym/101981/attachments The use of the triangle in the New Age practices s ...

  4. Codeforces Gym 100015B Ball Painting 找规律

    Ball Painting 题目连接: http://codeforces.com/gym/100015/attachments Description There are 2N white ball ...

  5. Codeforces Gym 100637B B. Lunch 找规律

    B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Des ...

  6. codeforces Gym 100418D BOPC 打表找规律,求逆元

    BOPCTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?c ...

  7. Gym 100917L Liesbeth and the String 规律&&胡搞

    题目: Description standard input/outputStatements Little Liesbeth likes to play with strings. Initiall ...

  8. Gym 101194A / UVALive 7897 - Number Theory Problem - [找规律水题][2016 EC-Final Problem A]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...

  9. Gym 101147A The game of Osho(SG找规律)

    https://vjudge.net/problem/Gym-101147A 题意:给出G组数,每组数包括两个数B,N,两玩家轮流取数,使得N-num,num<=N并且num是N的整次幂.判断谁 ...

随机推荐

  1. 为什么 Eclipse 里的 Classpath Variables M2_REPO 无法修改(non modifiable)

    本文转载自:http://uule.iteye.com/blog/2034097 解决方法: 在C:\Documents and Settings\Administrator\.m2中放入settin ...

  2. 转:利用UDEV服务解决RAC ASM存储设备名

    利用UDEV服务解决RAC ASM存储设备名 好文转载,链接:http://www.askmaclean.com/archives/utilize-udev-resolve-11gr2-rac-asm ...

  3. jdk中那些常见的类不能被继承的

    对于java中的类,如果是使用final修饰的话,那么这个类就不能够被继承,因为jdk的开发者认为,有一些最基本的类没要必要对开发者开放,如果用户 继承时操作有误,很可能引入很多问题.为了防止用户对基 ...

  4. 数据库:sql 多表联合更新【转】

    SQL Update多表联合更新的方法 (1) sqlite 多表更新方法 update t1 set col1=t2.col1 from table1 t1 inner join table2 t2 ...

  5. C++面向对象类的实例题目六

    问题描述: 编写一个程序计算两个给定长方形的面积,其中在设计类成员函数addarea()(用于计算两个长方形的总面积)时使用对象作为参数. 程序代码: #include<iostream> ...

  6. SQL serve 数据库--视图、事物、分离附加、备份还原

    视图是数据库中的一种虚拟表,与真实的表一样,视图包含一系列带有名称的行和列数据.行和列数据用来自定义视图的查询所引用的表,并且在引用视图时动态生成.  视图只能用来查询,不能增删改:不允许出现重复列 ...

  7. 时间获取_Date\SimpleDateFormat\Calendar类

     1.获取当前的日期,并把这个日期转换为指定格式的字符串,如2088-08-08 08:08:08 import java.text.SimpleDateFormat; import java.uti ...

  8. iOS 判断设备是否越狱了

    #import "PrisonBreakCheck.h" @implementation PrisonBreakCheck /** * 判断iPhone是否越狱了 */ +(BOO ...

  9. windows xp版本的chrome浏览器去哪里下载呢?

    http://www.265.com/chrome-download/?slice 265没记错的话应该是GOOGLE的一个导航网站吧,所以可信度是比较高的.

  10. Luogu 3292 [SCOI2016]幸运数字

    BZOJ 4568. 感觉很板. 前置技能:线性基.      放一篇感觉讲的比较丰富的博客: 戳这里. 首先要求在一个序列中任意选点使得异或和最大,当然是想到线性基了. 把问题转换到树上,如果每次询 ...