Solution

没有任何算法, 只要会$for$ 就能AC。。。

我们观察到, 如果有一个位置 的$F_i$ 的系数$b_i$ 为2, 那么只需要把 $b_{i-2}+1,b_{i+1}+1$即可。

$b_i = 1, b_{i-1}=1$,那么把$b_{i+1}+1$即可,

所以我们一直枚举过去, 直到没有可以更新的位置 , 就结束循环

Code

 #include<cstdio>
#include<cstring>
#include<algorithm>
#define rd read()
using namespace std; const int N = 1e6 + ; int ans[N], n, m, len, a[N], b[N]; int read() {
int X = , p = ; char c = getchar();
for (; c > '' || c < ''; c = getchar())
if (c == '-') p = -;
for (; c >= '' && c <= ''; c = getchar())
X = X * + c - '';
return X * p;
} int main()
{
n = rd;
for (int i = ; i <= n; ++i)
a[i] = rd;
m = rd;
for (int i = ; i <= m; ++i)
b[i] = rd;
for (int i = , up = max(n, m) + ; i <= up; ++i) {
ans[i] += a[i] + b[i];
if (ans[i] && ans[i - ])
ans[i]--, ans[i - ]--, ans[i + ]++;
if (ans[i] > ) {
if (i > )
ans[i - ]++;
ans[i + ]++;
ans[i] -= ;
}
}
for (int flag = ; flag;) {
flag = ;
for (int i = max(n, m) + ; i; --i) {
if (ans[i] && ans[i - ])
flag = , ans[i]--, ans[i- ]--, ans[i + ]++;
if (ans[i] > )
flag = , ans[i - ]++, ans[i + ]++, ans[i] -= ;
if (ans[] && !ans[])
ans[] += ans[], ans[] = ;
}
}
int up = max(n, m) + ;
while (!ans[up]) up--;
printf("%d", up);
for (int i = ; i <= up; ++i)
printf(" %d", ans[i]);
}

Luogu 3424 [POI2005]SUM-Fibonacci Sums的更多相关文章

  1. [CF126D]Fibonacci Sums/[BJOI2012]最多的方案

    [CF126D]Fibonacci Sums/[BJOI2012]最多的方案 题目大意: 将\(n(n\le10^9)\)表示成若干个不同斐波那契数之和的形式,求方案数. 思路: 如果不考虑\(0\) ...

  2. Codeforces 126D Fibonacci Sums 求n由随意的Sum(fib)的方法数 dp

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq574857122/article/details/34120269 题目链接:点击打开链接 题意 ...

  3. Codeforces Beta Round #93 (Div. 1 Only) D. Fibonacci Sums

    先考虑一个斐波那契数能分成其他斐波那契数的方案,假如f[i]表示第i个斐波那契数,那么只要对他进行拆分,f[i-1]这个数字必定会存在.知道这一点就可以进行递推了.先将数字分成最少项的斐波那契数之和, ...

  4. Luogu 3421 [POI2005]SKO-Knights - Exgcd

    Description 给出一个骑士的 $N$种 中行走的方式 $(a_i, b_i)$, 可以使骑士的坐标$(-a,-b)$或$(+a,+b)$. 我们需要找出 第二个骑士的 两种行走方式 $(c_ ...

  5. CF(D. Fibonacci Sums)dp计数

    题目链接:http://codeforces.com/contest/126/problem/D 题意:一个数能够有多种由互不同样的斐波那契数组成的情况: 解法:dp,easy证明:每一个数通过贪心能 ...

  6. Luogu 4868 Preprefix sum

    类似于树状数组维护区间的方法. 每一次询问要求$\sum_{i = 1}^{n}\sum_{j = 1}^{i}a_j$. 展开一下: $\sum_{i = 1}^{n}\sum_{j = 1}^{i ...

  7. luogu P3420 [POI2005]SKA-Piggy Banks

    题目描述 Byteazar the Dragon has NN piggy banks. Each piggy bank can either be opened with its correspon ...

  8. [LeetCode] Count of Range Sum 区间和计数

    Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Ra ...

  9. [Swift]LeetCode209. 长度最小的子数组 | Minimum Size Subarray Sum

    Given an array of n positive integers and a positive integer s, find the minimal length of a contigu ...

随机推荐

  1. 2018面向对象程序设计(Java)第4周学习指导及要求

    2018面向对象程序设计(Java) 第4周学习指导及要求(2017.9.19-2017.9. 26)   学习目标 掌握类与对象的基础概念,理解类与对象的关系: 掌握对象与对象变量的关系: 掌握预定 ...

  2. 1.3.8、CDH 搭建Hadoop在安装之前(端口---Apache Flume和Apache Solr使用的端口)

    Apache Flume和Apache Solr使用的端口 Apache Flume用于与Apache Solr通信的端口可能会有所不同,具体取决于您的配置以及是否使用安全性(例如,SSL).使用Fl ...

  3. Fiddler抓包域名过滤(转载)

    转载自 http://www.cnblogs.com/111testing/p/6440480.html Fiddler抓包域名过滤 我们在用Fiddler抓包的时候会抓到很多不需要的数据包,我们怎样 ...

  4. Linux下查看编辑二进制文件:hexedit神器

    1.如果没有hexedit安装hexedit:2.打开终端输入hexedit filename;3.打开即可用键盘输入字符,用方向键移动,ctrl+w保存,ctrl+x退出:4.详细用法 man he ...

  5. Python complex() 函数

    Python complex() 函数  Python 内置函数 描述 complex() 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数.如果第一个参数为字 ...

  6. c++三种进制格式

    来源:c++ primer plus 常用的进制有二进制,八进制,十进制,十六进制,在c++的头文件iostream里除了提供了endl控制符之外,还提供了控制进制的控制符,(不含二进制),分别是八进 ...

  7. jdbc java远程连接mysql数据库服务器

    首先,需要注意以下几点: 1.手机需要获得可以访问网络的权限: 2.导入的jdbc驱动的版本需要与mysql服务器的版本相近: 3.mysql默认的访客是只允许本机(localhost),不允许其他主 ...

  8. oracle 中从某天到某天一天一次执行某个函数

    DECLAREv_days INTEGER;v_start VARCHAR2(10);v_end VARCHAR2(10);v_3 INTEGER;v_enddays date;begin v_sta ...

  9. 最近读jdk源码一些基础的总结(有待后续深入)

    第一点:java.lang 1.Object类,hashCode()方法,equals()方法,clone()方法,toString()方法,notify()和notifyAll()方法,wait() ...

  10. Android Studio生成签名安装包(Generate Signed APK)

    一 打开构建对话框. 二 创建新的密钥库(key store) 可以选择已创建的密钥库,也可以选择创建新的密钥库. 创建完成后,自动导入. 三 选择签名类型. 如果不选,会提示错误. 这里将新旧两种签 ...