Codeforces450 B. Jzzhu and Sequences】的更多相关文章

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 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|,…
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…
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 calculat…
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…
题目链接: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…
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…
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…
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…
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/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的时候就会可能出现还是负数的情况,所以说交题之前最好测下极端的情况,因为…
题意:给出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…
题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | fn-1 | */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef __int64 LL; LL mod = 1e9 + ; struct data {…
题目: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…
# include <stdio.h> int f[10]; int main() { int x,y,n,j; while(~scanf("%d%d%d",&x,&y,&n)) { f[1]=x; f[2]=y; for(j=3;j<=6;j++) { f[j]=f[j-1]-f[j-2]; } n%=6; if(n==0) n=6; if(f[n]>=0) printf("%d\n",f[n]%1000000007…
矩阵快速幂. 首先得到公式 然后构造矩阵,用矩阵加速 取模函数需要自己写一下,是数论中的取模. #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…
题目链接: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…
Content 有一个长度为 \(n\) 的数列 \(\{a_1,a_2,\dots,a_n\}\),满足如下的递推公式: \(i=1\) 时,\(a_1=x\). \(i=2\) 时,\(a_2=y\). \(i\geqslant 3\) 时,\(a_i=a_{i-1}+a_{i+1}\). 求 \(a_n\bmod 10^9+7\) 的值. 数据范围:\(1\leqslant n\leqslant 2\times 10^9\),\(|x|,|y|\leqslant 10^9\). Solut…
B解题报告 算是规律题吧,,,x y z -x -y -z 注意的是假设数是小于0,要先对负数求模再加模再求模,不能直接加mod,可能还是负数 给我的戳代码跪了,,. #include <iostream> #include <cstring> #include <cstdio> using namespace std; long long x,y,z; long long n; int main() { cin>>x>>y; cin>&g…
A - Jzzhu and Children 找到最大的ceil(ai/m)即可 #include <iostream> #include <cmath> using namespace std; int main(){ int n,m; cin >> n >> m; ; ; ; i < n; ++ i){ cin >> a; if(maxv <= ceil(a/m)){ maxv = ceil(a/m); maxIdx = i+;…
A - Jzzhu and Sequences Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 450B Appoint description:  System Crawler  (2016-04-23) Description Jzzhu has invented a kind of sequences, they m…
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…
A - Jzzhu and Children Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th…
Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the chi…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…
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…