题目:Click here

题意:给定数列满足求f(n)mod(1e9+7)。

分析:规律题,找规律,特别注意负数取mod。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int M = 1e5+;
const int MOD = 1e9+; int x, y, n;
int a[];
int main() {
while( ~scanf("%d%d%d", &x, &y, &n ) ) {
a[] = x;
a[] = y;
for( int i=; i<; i++ ) {
if( i >= )
a[i] = a[i-] - a[i-];
while( a[i] < ) { //消除负数取mod的影响,将其转换成正数
a[i] += MOD;
}
a[i] %= MOD;
}
printf("%d\n", a[(n-)%] );
}
return ;
}

最新文章

  1. VIM插件攻略
  2. 来看看Windows9到底是什么
  3. 产品经理技能之MRD的笔记之一
  4. [转]javascript 快速隐藏/显示万行表格列的方法
  5. 配置android环境
  6. GEMR: Get the parent window for view
  7. ListView具有多种item布局——实现微信对话列
  8. android notification 传值关键
  9. JavaScript系列:常用方法
  10. 【Delphi】注册快捷键
  11. java 手动清理缓存的方法
  12. 怎么限制Google自己主动调整字体大小
  13. CSS换行2
  14. 【head first python】学习计划
  15. 打印ASCII码
  16. C++第一课:基本语法for Visual Studio 2015[个人见解]
  17. C语言的“编译、链接”
  18. zabbix的api接口
  19. 启动Jenkins
  20. Pycharm主题设置以及导入方式

热门文章

  1. mac上搭建svn服务器
  2. Struts2,Spring,Hibernate三大框架的整合(SSH)
  3. bzoj 1042: [HAOI2008]硬币购物 dp+容斥原理
  4. Python 爬取CSDN博客频道
  5. 前端笔试题2 JS部分
  6. Android开源项目(一)
  7. 运行于64操作系统上的C#客户端通过WCF访问Oracle数据库不兼容问题
  8. 【LeetCode】Flatten Binary Tree to Linked List
  9. 【C++学习笔记】继承与派生基础概念
  10. js静态方法和实例方法