cf B. The Fibonacci Segment】的更多相关文章

http://codeforces.com/contest/365/problem/B #include <cstdio> #include <cstring> #include <algorithm> #define maxn 200010 #define LL __int64 using namespace std; int n; LL a[maxn]; int main() { while(scanf("%d",&n)!=EOF) {…
You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r). Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment…
题目链接:http://codeforces.com/problemset/problem/365/B 题目意思:简单来说,就是要找出最长的斐波纳契长度. 解决的方法不难,但是要注意更新左区间和右区间的值,而且需要把当前求出的斐波纳契长度和之前求出的斐波纳契长度进行对比,以便更新得出的最长的斐波纳契长度. 特别注意的是,序列只有一个.两个或者没有斐波纳契长度的处理. #include <iostream> #include <cstdio> #include <cstdlib…
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); ; i < n; ++ i) cin >> a[i]; ; ) maxlen = ; ) maxlen = ; else{ maxlen = ; , r =; ; i <…
#include <stdio.h> #include <string.h> bool vis[11]; int n, k; bool judge(int x) { memset(vis, false, sizeof(vis)); if (x == 0) vis[0] = true; while (x) { vis[x%10] = true; x /= 10; } for (int i = 0; i <= k; i++) if (vis[i] == false) return…
题意 给你一个长度为 \(n\) 的序列 \(a\),有 \(m\) 次操作,操作分两种 \(\text{1}\space \text{l}\space \text{r}\space \text{x}\).区间加: \(\text{2}\space \text{l}\space \text{r}\).求 \(\sum\limits_{i=l}^{r} \text{fib}(a_i) \mod (10^9+7)\) \(\text{fib}(i)\) 表示斐波那契数列第 \(i\) 项,初始值为…
The Fibonacci Segment CodeForces - 365B You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r). Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r].…
题目:http://codeforces.com/contest/914/problem/G 其实就是把各种都用子集卷积和FWT卷起来算即可: 注意乘 Fibonacci 数组的位置: 子集卷积时不能一边做一边更新卷积的数组! 代码如下: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int rd() { ,f=; cha…
题目大意 \(t\le 10^5\)组询问 每次询问\(1\le n\le 10^{18}\) 求有多少种\(n\)的\(fibonacci\)分解 分解定义为:每个\(fib\)数最多选一个,且和为\(n\) 分解出来的数是无序的 分析 妙不可言 可以先将\(n\)分解无相邻\(1\)的\(fib\)码 对于每个\(1\),可以拆分成\(1\),\(011\),\(01011\),\(0101011\),\(\cdots\)(最高位对齐) 然后再通过\(dp\)求解答案 单词复杂度为\(O(\…
题目:http://codeforces.com/contest/914/problem/G 第一个括号可以子集卷积:第三个括号可以用 FWT 异或卷积:这样算出选两个数组成 x 的方案数:三个部分的方案数分别乘上 f[ x ] 再一起与卷积即可. 注意子集卷积的时候不要改 tp[ i ][ s ] ,因为要的是恰好两个数拼起来,没有改过的(但是做过 FMT 的) tp[ i ][ s ] 存的是初值,表示选 1 个数的方案数. 所以如果可以选任意多个数,就可以像背包一样, tp[ j ][ s…