Pell Sequence
/*
* 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的更多相关文章
- oracle SEQUENCE 创建, 修改,删除
oracle创建序列化: CREATE SEQUENCE seq_itv_collection INCREMENT BY 1 -- 每次加几个 STA ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
- DG gap sequence修复一例
环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Sequence Reconstruction 序列重建
Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...
- [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [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 ...
- [LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...
- [LeetCode] Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
随机推荐
- LDA主题模型(理解篇)
何谓“主题”呢?望文生义就知道是什么意思了,就是诸如一篇文章.一段话.一个句子所表达的中心思想.不过从统计模型的角度来说, 我们是用一个特定的词频分布来刻画主题的,并认为一篇文章.一段话.一个句子是从 ...
- git常用命令和github
工作区:就是你的工作目录 暂存区:它像个缓存区域,临时保存你的改动 版本区:就是你的git仓库 HEAD:相当于一个指针,指向你最近一次提交后的结果 git status 查看状态 git add . ...
- vs2017 visual studio2017 密钥 激活码
企业版Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF 专业版Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
- (转) 淘淘商城系列——使用SolrJ查询索引库
http://blog.csdn.net/yerenyuan_pku/article/details/72908538 我们有必要在工程中写查询索引库的代码前先进行必要的测试.我们先到Solr服务页面 ...
- redis的安装和使用【2】redis的java操作
修改redis.conf# 配置绑定ip,作者机子为192.168.100.192,请读者根据实际情况设置bind 192.168.100.192#非保护模式protected-mode no保存重启 ...
- WEB前端响应式布局之BootStarp使用
1.Bootstrap简介:1. 概念: 一个前端开发的框架,Bootstrap,来自 Twitter,是目前很受欢迎的前端框架.Bootstrap 是基于 HTML.CSS.JavaScript 的 ...
- Tomcat 使用redis实现session共享
准备工作: 1.安装nginx 环境搭建参考:https://blog.csdn.net/fd2025/article/details/79878326 nginx.conf的编辑: 2.同一台机器配 ...
- 可以通过dict[key]获得dict[value]
dict={key:value,key2:value2} print (dict[key] ) 得到的是 dict[value] # 软文预存接口,通过key来预览未保存的软文,联查商品.kol ...
- 抓包工具的感触(charles and fiddler)
最近测mobile,一直徘徊在fiddler 和 charles之间: charles 的证书装了 ,才能正常抓包: 后来因为重定向,分享到扣扣,微信的跳转功能,跳转到wap 或者跳转到PC 或者跳 ...
- Jmeter BeanShell PreProcessor使用笔记
打印log log.info("content:" + content); 将字符串转化为JsonString import com.alibaba.fastjson.JSON; ...