/*
* PellSequence.cpp
*
* Created on: 2013-09-08 16:46
* Author: lg
* Description: a1 = 1, a2 = 2, ... , an = 2 * an − 1 + an - 2 (n > 2)
* ans = an % 32767
*/
#include <stdio.h> int PellMod(int); int main()
{
int tc, n;
scanf("%d", &tc);
while(tc--){
scanf("%d", &n);
printf("%d\n", PellMod(n));
}
return 0;
} int PellMod(int n)
{
if(n == 1) return 1;
int ans[2] = {1, 2}, j = 0;
for(int i = 2; i < n; j = 1 - j, i++){
ans[j] += 2 * ans[1 - j];
ans[j] %= 32767;
}
return ans[1 - j];
}

Pell Sequence的更多相关文章

  1. oracle SEQUENCE 创建, 修改,删除

    oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              STA ...

  2. Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等

    功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...

  3. DG gap sequence修复一例

    环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...

  4. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  5. [LeetCode] Sequence Reconstruction 序列重建

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...

  6. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  7. [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

  8. [LeetCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  9. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

随机推荐

  1. 调度kettle使用taskctl我该怎么部署

    转载自: http://www.taskctl.com/forum/detail_133.html 最近在QQ群看到有小伙伴在问用taskctl调度kettle,都要安装些什么呢?都支持哪些平台上的k ...

  2. Git——github高级

    分支管理 分支不是越多越好,只求一个稳定的分支,即master不要轻易去更改 对应master要有一个开发者分支,保证mater分支的稳定性 所有的功能都在开发者分支上进行 在所有功能开发后新建发布分 ...

  3. echarts之我用

    最近在用echarts做项目,抽点时间总结一下. 首先说一下什么是echarts.echarts是百度开发的类似于fusioncharts的图表展示控件.区别于fusioncharts的是echart ...

  4. MERGE INTO USING用法

    MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your ...

  5. (转)淘淘商城系列——使用solrj来测试索引库

    http://blog.csdn.net/yerenyuan_pku/article/details/72892280 我们使用solrj来操作索引库,一般习惯先建一个单元测试类测试下增删改查方法是否 ...

  6. Robot Framework(九) 执行测试用例——基本用法

    3.1基本用法 Robot Framework测试用例从命令行执行,默认情况下,最终结果是XML格式的输出文件和HTML 报告和日志.执行后,可以组合输出文件,然后使用rebot工具进行后处理. 3. ...

  7. 19MVC设计模式

    MVC设计模式 MVC英文即Model-View-Controller, 即把一个应用的输入.处理.输出流程按照Model.View.Controller的方式进行分离,这样一个应用被分成三个层——模 ...

  8. 牛客多校Round 4

    Soved:3 rank:133 A.Ternay String 欧拉降幂一下 但是反复求phi会超时 但mod是同一个就可以记忆化一下 #include <bits/stdc++.h> ...

  9. BZOJ3124: [Sdoi2013]直径 (树形DP)

    题意:给一颗树 第一问求直径 第二问求有多少条边是所有直径都含有的 题解:求直径就不说了 解第二问需要自己摸索出一些性质 任意记录一条直径后 跑这条直径的每一个点  如果以这个点不经过直径能到达最远的 ...

  10. Window下的———TOMCAT环境的配置

    1. 先去官方网站下载需要的猫(tomcat) http://tomcat.apache.org/ 2.下载好包,然后解压出来,放在你需要的位置上 3.去到配环境变量的地方,进行相应的环境配置     ...