题目链接:http://codeforces.com/problemset/problem/908/G

题解:dp[i][j][x][l]代表前i个数中有j个数>=x, l代表是否已经抵达n这个数的边界。

num = dp[i][j][x][0]+dp[i][j][x][1]代表前i个数中有j个数>=x的总方案数。

如果某一位上为3,则3>=1, 3>=2, 3>=3的时候, 考虑了3次,所以可以看做排序后的最后j个数全为1.

所以num*111111(共j个1)代表前i个数中有j个数>=x的值。

#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int MX = 707;
int dp[MX][MX][10][2];
int a[MX];
char s[MX];
const int mod = 1e9+7;
int main()
{scanf("%s",s+1);int n = strlen(s+1);for(int i = 1; i <= n; i++)a[i] = s[i] - '0';
//    cout<<a[1]<<" "<<a[2]<<endl;for(int i = 1; i <= 9; i++) dp[0][0][i][1] = 1;for(int x = 1; x <= 9; x++)for(int i = 0; i < n; i++)for(int j = 0; j <= i; j++)for(int l = 0; l < 2; l++)for(int  p = 0; p <= (!l? 9 : a[i+1]); p++)(dp[i+1][j+(p>=x)][x][l&(p==a[i+1])] += dp[i][j][x][l])%=mod;LL res = 0;for(int i = 1; i <= 9; i++){LL temp = 1;for(int j = 1; j <= n; j++)res = (res+(dp[n][j][i][0]+dp[n][j][i][1])*temp%mod)%mod, temp = (temp*10+1)%mod;}cout<<res<<endl;return 0;
}

[CodeForces908G]New Year and Original Order相关推荐

  1. Good Bye 2017 G. New Year and Original Order 数位dp + 按数贡献

    传送门 文章目录 题意: 思路: 题意: 定义S(k)S(k)S(k)为将kkk的每一位拿出来从小到大排序后构成的数,比如S(3421)=1234S(3421)=1234S(3421)=1234,求S ...

  2. CF908G. New Year and Original Order

    CF908G. New Year and Original Order Solution 对于一个数xxx,它的贡献为排序之后的值,例如:S(50394)=3459=3∗103+4∗102+5∗101 ...

  3. CF908G New Year and Original Order

    http://codeforces.com/problemset/problem/908/G 题解 考虑一个数的答案怎么算. 比如说32214. 我们求出大于等于1的数的个数,为5个,那么加上5*11 ...

  4. CF908G New Year and Original Order 数位DP

    传送门 看到数据范围到\(10^{700}\)毫无疑问数位DP.那么我们最重要的问题是如何有效地维护所有数位排序之后的数的值. 对于某一个数\(x\),设\(f_{x,i} (i \in [1,9]) ...

  5. Google Test(GTest)使用方法和源码解析——结果统计机制分析

    在分析源码之前,我们先看一个例子.以<Google Test(GTest)使用方法和源码解析--概况 >一文中最后一个实例代码为基准,修改最后一个"局部测试"结果为错误 ...

  6. 如何在JavaScript中切片和拼接数组

    .slice() and .splice() are similar methods in JavaScript. They look similar, they sound similar, and ...

  7. mysql select 返回列,是否可以对在mysql SELECT语句中返回列的顺序进行排序?

    Imagine two questions from an online survey: Do you like apples? Result stored in mysql db column &q ...

  8. LeetCode:937. Reorder Log Files

    051401 题目 You have an array of logs. Each log is a space delimited string of words. For each log, th ...

  9. Java初学者必看2

    1.数组 ①数组的定义 在Java中,定义数组有两种方法 <pre name="code" class="java"> int[] n=new in ...

最新文章

  1. ICCV 2021 Workshop 盘点
  2. java基于servlet的文件上传
  3. 大学计算机英语句子,大学英语作文万能句子
  4. 关于深度学习、NLP和计算机视觉的30个顶级Python库
  5. 在 libevent 中使用 MariaDB(MySQL)
  6. iOS-开启arc之后 NSNotificationCenter removeObserver 是否需要调用
  7. 如何创建新的SAP CRM middleware subscription
  8. 创建QT项目只有一个pro文件
  9. C# 判断给定大数是否为质数,目标以快速度得到正确的计算结果。
  10. ae画面颜色一键选取替换修改插件Composite Brush for Mac 1.5.2
  11. 安全强化linux-SELinux
  12. Bootstrap3 Affix插件
  13. Ubuntu安装sysv-rc-conf配置开机启动服务
  14. web.xml中配置DispatcherServlet前端控制器和CharacterEncodingFilter字符过滤器后web-app标签显红报错
  15. jquery 自定义事件
  16. 解决【npm ERR! Unexpected end of JSON input while parsing near '...sh_time:141072930277'】方案...
  17. MATLAB深度学习 2019
  18. C/C++程序之根据有向图、无向图求通路、回路、可达矩阵
  19. 系统规划与管理师历年论文
  20. CSS3——渐变(线性渐变、径向渐变、重复性渐变)

热门文章

  1. 高精度4位压缩法原理与实现
  2. MATLAB绘图(特殊二维)
  3. 频繁模式挖掘——概述
  4. vue的头像生成神奇
  5. 省选+NOI 第一部分 动态规划DP
  6. 关于 /dev/urandom 的流言终结
  7. 思博伦Tweakker赢得亚洲首个 MVNO合同
  8. Navicat可视化界面导入SQL文件生成数据库表
  9. ISP——DPC(Defective Pixel Correction)
  10. 《STM32从零开始学习历程》——CAN通讯协议协议层