给出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. who命令参数及用法详解(linux查看在线用户命令)

    功能说明:显示目前登入系统的用户信息.  语 法:who [-Himqsw][--help][--version][am i][记录文件]  补充说明:执行这项指令可得知目前有那些用户登入系统,单独执 ...

  2. HTTP:HTTP清单

    ylbtech-HTTP:HTTP清单 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbt ...

  3. Oracle session出现大量的inactive

    一.官网说明 1.1 processes 11gR2 的文档: Property Description Parameter type Integer Default value 100 Modifi ...

  4. CRC 简介

    CRC wiki,历史发展,各个版本的用途 等 https://en.wikipedia.org/wiki/Cyclic_redundancy_check (apple)crc32.c /* * Th ...

  5. Ubuntu 下 ROS Kinetic 的安装

    安装环境为 Ubuntu 16.04 配置 Ubuntu 软件仓库 打开“设置”中的“软件和更新” 把 “restricted”.“universe” 和 “multiverse” 这三项勾上 勾完后 ...

  6. spring Annotation

    使用注解替代xml 在前几章的笔记基础上添加使用注解的形式 1.配置applicationContext 添加context schema <?xml version="1.0&quo ...

  7. 注解:@interface 自定义注解的语法

      自定义注解: 使用@interface自定义注解时,自动继承了java.lang.annotation.Annotation接口,由编译程序自动完成其他细节.在定义注解时,不能继承其他的注解或接口 ...

  8. taskkill /f /t /im processName

    /*@echo off */taskkill /f /t /im WINWORD.exetaskkill /f /t /im nginx.exetaskkill /f /t /im w3wp.exet ...

  9. ghld data format

    %CTF: 1.00%FileType: PROF strp "VelocityProfile"%PROFSpec: 1.00 2006 00 00%Manufacturer: C ...

  10. Tiny4412 u-boot分析(1)u-boot配置流程分析

    参考Friendlyarm的文档,编译uboot的流程为 make tiny4412_config make 这个过程主要涉及到两个文件,顶层的Makefile文件和mkconfig文件,makeco ...