题目链接:http://codeforces.com/contest/450/problem/B 解题报告:f1 = x,f2 = y,另外有当(i >= 2) fi = fi+1 + fi-1,现在给出x和y,k,让你输出fn % (1e9+7) 对于这题我真想说细节决定一切,f的值一共只有6个,只要把f的值全部打表打出来了就可以直接得出任何一个fk的值. 但是注意x和y的范围都是小于10^9,所以当(x+y) % MOD的时候就会可能出现还是负数的情况,所以说交题之前最好测下极端的情况,因为…
题目链接: B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculat…
题意:给出f1=x,f2=y,f(i)=f(i-1)+f(i+1),求f(n)模上10e9+7 因为 可以求出通项公式:f(i)=f(i-1)-f(i-2) 然后 f1=x; f2=y; f3=y-x; f4=-x; f5=-y; f6=-y+x; f7=x; 发现是以6为循环的 还有注意下余数为正,就每次加上一个mod再模上mod #include<iostream> #include<cstdio> #include<cstring> #include <cm…
CodeForces 450B Jzzhu and Sequences (矩阵优化) Description Jzzhu has invented a kind of sequences, they meet the following property: \[f_1=x\] \[f_2=y\] \[f_i=f_{i-1}+f_{i+1}\text {(i>2)}\] You are given x and y, please calculate fn modulo 1000000007 (10…
题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following pr…
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn m…
题目链接:https://vjudge.net/problem/CodeForces-450B B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following proper…
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn m…
CF450B Jzzhu and Sequences 大佬留言:这.这.不就是矩乘的模板吗,切掉它!! You are given xx and yy , please calculate $f_{n}(mod(10^{9}+7))$. 原式:$f_{i}=f_{i-1}+f_{i+1}$ 转换一下:$f_{i+1}=f_{i}-f_{i-1}$ 相当于$f_{i}=f_{i-1}-f_{i-2}$ 有没有发现它跟斐波那契通项公式有点儿类似? 的确是这样的,那么转移矩阵也类似: $0 -1$ $…
A - Jzzhu and Sequences   Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Input The first line contains two integers x and y (|x|, |y| ≤ 109). The secon…