题意:

长为 n,由 l ~ r 中的数组成,其和模 3 为 0 的数组数目。

思路:

dp[ i ][ j ] 为长为 i,模 3 为 j 的数组数目。

#include <bits/stdc++.h>
using namespace std; const int M=220000;
const int mod=1e9+7; long long dp[M][3]; int main()
{
int n,l,r;cin>>n>>l>>r; for(int i=0;i<3;i++)
dp[1][i]=(r+3-i)/3-(l+3-i-1)/3; for(int i=2;i<=n;i++)
for(int j=0;j<3;j++)
for(int k=0;k<3;k++)
dp[i][j]=(dp[i][j]+dp[i-1][k]*dp[1][(3+j-k)%3]%mod)%mod; cout<<dp[n][0]; return 0;
}

参考:求区间内能被n整除%n==0,%n==1,%n==2....的个数

Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array(递推)的更多相关文章

  1. Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array 【dp】

    传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 secon ...

  2. Codeforces Round #533(Div. 2) C.Ayoub and Lost Array

    链接:https://codeforces.com/contest/1105/problem/C 题意: 给n,l,r. 一个n长的数组每个位置可以填区间l-r的值. 有多少种填法,使得数组每个位置相 ...

  3. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

  4. Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS

    题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...

  5. Codeforces Round #533 (Div. 2) Solution

    A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N ...

  6. Codeforces Round #533 (Div. 2) B. Zuhair and Strings 【模拟】

    传送门:http://codeforces.com/contest/1105/problem/B B. Zuhair and Strings time limit per test 1 second ...

  7. Codeforces Round #533(Div. 2) D.Kilani and the Game

    链接:https://codeforces.com/contest/1105/problem/D 题意: 给n*m的地图,最多9个人,同时有每个人的扩张次数(我开始以为是直线扩张最大长度..实际是能连 ...

  8. Codeforces Round #533(Div. 2) B.Zuhair and Strings

    链接:https://codeforces.com/contest/1105/problem/B 题意: 给一个字符串和k,连续k个相同的字符,可使等级x加1, 例:8 2 aaacaabb 则有aa ...

  9. Codeforces Round #533(Div. 2) A.Salem and Sticks

    链接:https://codeforces.com/contest/1105/problem/A 题意: 给n个数,找到一个数t使i(1-n)∑|ai-t| 最小. ai-t 差距1 以内都满足 思路 ...

随机推荐

  1. 浅谈.NET技术公司的实习生培养

    浅谈.NET技术公司的实习生培养 背景 近几年.NET开发者市场的越发不景气,一毕业就选择.NET技术的开发者更是少之又少.一方面是公司效益的日益提高,一方面却是招聘优秀人才的速度总是赶不上公司发展的 ...

  2. 【Flutter】功能型组件之异步UI更新

    前言 很多时候会依赖一些异步数据来动态更新UI,比如在打开一个页面时我们需要先从互联网上获取数据,在获取数据的过程中我们显示一个加载框,等获取到数据时我们再渲染页面:又比如想展示Stream(比如文件 ...

  3. 搭建docker环境,安装常用应用(单机)

    ## 安装docker ```bash1.卸载系统之前dockersudo yum remove docker \ docker-client \ docker-client-latest \ doc ...

  4. xtrabackup迁移mysql5.7.32

    问题描述:利用外部xtrabackup工具来做迁移mysql数据库,或者恢复数据库 xtrabackup迁移mysql 1.环境 mysql源库 mysql目标迁移库 IP 192.168.163.3 ...

  5. 【ORACLE】ASMM和AMM的相关问题

    转自:http://m.blog.itpub.net/31397003/viewspace-2137469/ 关于ASMM和AMM http://blog.itpub.net/29800581/vie ...

  6. ECC 6 debuging中create points

    2013-12-07 今天无意中,发现,在ECC6中debug的时候,创建动态断点,对于command中的delete from语句居然无效,唉 虽然设置了DELETE 和DELETE FROM两个动 ...

  7. js千分位分隔,数字货币化方法学习记录

    js千分位分隔,数字货币化-4种方法(含正则) 方法1-整数货币化 // 整数货币化 function intCurrency(num) { var reg = new RegExp("^[ ...

  8. apk开发环境!多亏这份《秋招+金九银十-腾讯面试题合集》跳槽薪资翻倍!再不刷题就晚了!

    开头 最近很多网友反馈:自己从各处弄来的资料,过于杂乱.零散.碎片化,看得时候觉得挺有用的,但过个半天,啥都记不起来了.其实,这就是缺少系统化学习的后果. 为了提高大家的学习效率,帮大家能快速掌握An ...

  9. Oracle 0至6级锁的通俗解释及实验案例_ITPUB博客 http://blog.itpub.net/30126024/viewspace-2156232/

    Oracle 0至6级锁的通俗解释及实验案例_ITPUB博客 http://blog.itpub.net/30126024/viewspace-2156232/

  10. the code has to work especially hard to keep things in the same thread

    django/asgiref: ASGI specification and utilities https://github.com/django/asgiref/