给出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. 什么是VBA,他有什么作用

    目录 什么是VBA,它有什么作用 VBA在哪里存放的?怎么运行的 什么是宏?宏和VBA有什么关系? 录制一个宏 编写第一个宏 一.什么是VBA,它有什么作用 VBA是一种编程语言,它依托于Office ...

  2. Oracle 常见进程

    1 服务器进程 专用服务器连接:数据连接跟服务器上的一个进程之间存在1:1的映射 共享服务器连接:多个会话共享一个服务器进程池,由一个调度程序分配 1.1 专用服务器连接 专用服务器连接模式下,客户连 ...

  3. javascript——对象的概念——内建对象

    包括内建对象的所有对象都是Object对象的子对象. 1.Array():构建数组的内建构造器函数 例:创建数组方式有两种: 2.Boolean:是对象,与基本数据类型 布尔值 不相同 例:创建Boo ...

  4. eclipse中maven的配置与使用

    以eclipse Juno版本为例 1.插件安装 eclipse==>help====>install new software===>add name :m2e location: ...

  5. [Python Study Notes]折线图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  6. JAVA基础知识总结8(设计模式)

    设计模式:JAVA中有23种设计模式 1.解决问题最行之有效的思想. 2.是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结. 3.使用设计模式是为了可重用代码.让代码更容易被他人理解 ...

  7. Ajax入门(二)Ajax函数封装

    如果看了的我上一篇博客<Ajax入门(一)从0开始到一次成功的GET请求>的话,肯定知道我们已经完成了一个简单的get请求函数了.如下: 1234567891011121314151617 ...

  8. 关于android studio中使用class.forname()方法动态获取类实例报NO CLASS FOUND异常的几种处理方法

    最近在做一个项目的时候需要用到反射来回调子类的方法,但是在反射过程中总是在class.forname()方法抛出NO CLASS FOUND异常,经过几部检查,问题解决,在此总结一下引起该问题的原因 ...

  9. CDOJ1324-卿学姐与公主 【线段树点更新】

    http://acm.uestc.edu.cn/#/problem/show/1324 卿学姐与公主 Time Limit: 2000/1000MS (Java/Others)     Memory ...

  10. c++的单例模式及c++11对单例模式的优化

    单例模式 单例模式,可以说设计模式中最常应用的一种模式了,据说也是面试官最喜欢的题目.但是如果没有学过设计模式的人,可能不会想到要去应用单例模式,面对单例模式适用的情况,可能会优先考虑使用全局或者静态 ...