题目:Click here 题意:给定数列满足求f(n)mod(1e9+7). 分析:规律题,找规律,特别注意负数取mod. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; ; ; int x, y, n; ]; int main() { while( ~scanf…
题目链接: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…
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…
#pragma once #include <iostream> using namespace std; template <typename T> double *wMA(T &tArray, int iWMALen) // 应用模版数据类型 typename T 引用外部数组 tArray { ]); // 计算传入数组长度 = 总数组字节大小 / 首元素字节大小 cout << "Length of import array is: "…
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 second line contains a single i…
题目链接:http://codeforces.com/problemset/problem/450/B 题目意思:给出 f1 和 f2 的值,以及n,根据公式:fi = fi-1 + fi+1,求出fn是多少. 这题通过手工模拟,可以发现它有一个周期的:以6为周期! f1 = f1,   f2 = f2,   f3 = f2 - f1 f4 = -f1,  f5 = -f2,  f6 = -f2 + f1 以前从来不知道负数的模怎么求,这题刚好考到!其实根据第二个test约莫猜到,就是要加上要m…
矩阵快速幂. 首先得到公式 然后构造矩阵,用矩阵加速 取模函数需要自己写一下,是数论中的取模. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; ; long long x, y; int n; long long mod(long long a, long long b) { )…
思路: 之前那篇完全没想清楚,给删了,下午一上班突然想明白了. 讲一下这道题的大概思路,应该就明白矩阵快速幂是怎么回事了. 我们首先可以推导出 学过矩阵的都应该看得懂,我们把它简写成T*A(n-1)=A(n),是不是有点像等比?然后我们得到T^(n-1)*A(1)=A(n),所以我们可以通过矩阵快速幂快速计算左边的T^n-1这个式子,最后再和A1相乘,那么第一个数字就是答案了. 代码: #include<set> #include<cstring> #include<cstd…
Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/102400 K (Java/Others)Total Submission(s): 250    Accepted Submission(s): 169 Problem Description I've sent Fang Fang around 201314 text messages in almost 5 years. Why can't she make sens…
C. Pie or die Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/C Description Volodya and Vlad play the following game. There are k pies at the cells of n  ×  m board. Each turn Volodya moves one pie to the neighbo…