题意:

长为 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. 计算机考研复试 A+B

    题目描述 读入两个小于100的正整数A和B,计算A+B. 需要注意的是:A和B的每一位数字由对应的英文单词给出. 输入描述: 测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B ...

  2. 基于Python的接口自动化-读写excel文件

    引言 使用python进行接口测试时常常需要接口用例测试数据.断言接口功能.验证接口响应状态等,如果大量的接口测试用例脚本都将接口测试用例数据写在脚本文件中,这样写出来整个接口测试用例脚本代码将看起来 ...

  3. tensorflow安装使用过程错误及解决方法

    tensorflow2.x 使用过程中常见错误(持续更新) 安装配置,使用tensorflow训练模型,转换为tflite模型,并部署与移动端过程中,虽然不难,但是也常出现一些莫名其妙的问题,下面简单 ...

  4. 7.prometheus之查询API

    一.格式概述 二.表达式查询 2.1 Instant queries(即时查询) 2.2 范围查询 三.查询元数据 3.1 通过标签匹配器找到度量指标列表 3.2 获取标签名 3.3 查询标签值 四. ...

  5. Centos7安装Jenkins和目录迁移

    Centos7安装Jenkins和目录迁移 内容: 安装Jenkins和相关的配置 尝试目录迁移,模拟磁盘空间不足 1. 安装Jenkins和配置 安装 根据Jenkins的官方安装指引,安装步骤如下 ...

  6. sort方法和sorted()函数

    sort方法和sorted()函数的区别: 相同点:都能完成排序操作. 不同点: (1)使用sort()方法对list排序会修改list本身,不会返回新list,sort()不能对dict字典进行排序 ...

  7. python模块/文件/日期时间

    文件操作:

  8. 【Linux】CentOS4 系统最后的网络yum源

    ------------------------------------------------------------------------------------------------- | ...

  9. oracle新增ID主键列,如何补全旧数据的ID值

    1.创建SEQUENCE CREATE SEQUENCE MONKEY.TEST_ADD_IDCOL_ID CACHE 100; 2.新增表栏位 ALTER TABLE MONKEY.TEST_ADD ...

  10. Windows环境下搭建FTP服务器

    Windows主机建立FTP服务器 第一步:启用对应的Windows功能 控制面板 选择启用或关闭Windows功能 勾选FTP服务器和Web管理工具 可能出现的问题 系统提示无法安装IIS和FTP服 ...