给出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. Java基础--枚举Enum

    Java中的枚举是一种特殊的类,可以将一组固定常量的集合组成一种类型,使用方便且类型安全.使用enum关键字定义. enum类型父类为Enum,通过Enum.class可见Enum为抽象类,实现了Co ...

  2. (转)SC Create 创建一个Windows系统服务

    本文转载自:http://blog.sina.com.cn/s/blog_62b8fc330100l9px.html C:\Users\sophiaX>sc 描述: SC 是用于与服务控制管理器 ...

  3. DataGridview刷新异常的问题

    datsSet 绑定到dataGrieView,在刷新dataSet的数据时,常会bug:索引0没有值或索引(int)x没有值 昨天弄了一个下午,发现bug原因: dataGridView中有数据时, ...

  4. wpf数据验证实例及常用方法小结

    虽然标题是wpf数据验证,但并不是对IDataErrorInfo.ValidationRule.属性中throw Exception这几种验证方式的介绍: 之前做项目时(例如员工工资管理),根据员工编 ...

  5. 新建 FrameMaker API 时引用目录的设置

    如果将FDK安装目录下的Sample项目拷贝到其它目录编译,往往会报错 c1083 找不到fapi.h等头文件,或者Link时报错找不到.lib文件. 1.可通过菜单-项目-xxx属性-配置属性-c/ ...

  6. Json-lib 进行java与json字符串转换之二

    二.list和json字符串的互转 list-->>json字符串 public static void listToJSON(){ Student stu=new Student(); ...

  7. DDD学习笔录——简介DDD的战略模式如何塑造应用程序的架构

    前一篇,简单介绍了DDD战略模式的提炼问题域,这篇简单介绍它如何塑造应用程序的架构. 1.创建一个模型以解决领域问题 为每一个子域构建一个软件模型以处理领域问题并让软件与业务保持一致. 这个模型并非现 ...

  8. 关于EMGCU中的cvertern.dll无法找到的问题

    方法1:自己到EMgucv目录的bin里面拷贝x86文件夹到自己程序的debug目录 方法2:将这个X86目录添加到PATH变量,记得要注销,否则新添加的无法起作用,VS2010还显示无法找到.

  9. IOS AppStore上线前测试

    IOS  AppStore上线前测试 TestFlight Beta ios 8才开始支持. https://developer.apple.com/library/ios/documentation ...

  10. 【转】Android下面打印进程函数调用堆栈(dump backtrace)的方法

    1. 为什么要打印函数调用堆栈? 打印调用堆栈可以直接把问题发生时的函数调用关系打出来,非常有利于理解函数调用关系.比如函数A可能被B/C/D调用,如果只看代码,B/C/D谁调用A都有可能,如果打印出 ...