数位DP部分,不是很难。DP[i][j]前i位j个幸运数的个数。枚举写的有点搓。。。

 #include <cstdio>
#include <cstring>
using namespace std;
#define LL __int64
#define MOD 1000000007
int dp[][];
int p[],num;
int o[];
int dfs(int pos,int pre,int bound)
{
int ans,i,end;
ans = ;
if(pos == -)
return pre == ;
if(!bound&&dp[pos][pre] != -)
return dp[pos][pre];
end = bound ? p[pos]:;
for(i = ;i <= end;i ++)
{
if(i == ||i == )
ans += dfs(pos-,pre-,bound&&i == end);
else
ans += dfs(pos-,pre,bound&&i == end);
}
if(!bound)
dp[pos][pre] = ans;
return ans;
}
void CL(int m)
{
num = ;
while(m)
{
p[num++] = m%;
m /= ;
}
}
int main()
{
int i,m;
int a1,a2,a3,a4,a5,a6,sum;
LL ta1,ta2,ta3,ta4,ta5,ta6;
LL ans,t1,t2;
memset(dp,-,sizeof(dp));
scanf("%d",&m);
CL(m);
for(i = ;i <= ;i ++)
{
o[i] = dfs(num-,i,);
}
o[] --;
ans = ;
for(a1 = ;a1 <= ;a1 ++)
{
ta1 = o[a1];
o[a1] -- ;
for(a2 = ;a2 <= &&o[a1] >= ;a2 ++)
{
ta2 = o[a2];
o[a2] -- ;
for(a3 = ;a3 <= &&o[a2] >= ;a3 ++)
{
ta3 = o[a3];
o[a3] -- ;
for(a4 = ;a4 <= &&o[a3] >= ;a4 ++)
{
ta4 = o[a4];
o[a4] -- ;
for(a5 = ;a5 <= &&o[a4] >= ;a5 ++)
{
ta5 = o[a5];
o[a5] -- ;
for(a6 = ;a6 <= &&o[a5] >= ;a6 ++)
{
ta6 = o[a6];
o[a6] -- ;
sum = a1 + a2 + a3 + a4 + a5 + a6;
if(sum <= &&o[a6] >= )
{
t1 = ta1;
t1 = t1*ta2%MOD;
t1 = t1*ta3%MOD;
t1 = t1*ta4%MOD;
t1 = t1*ta5%MOD;
t1 = t1*ta6%MOD;
t2 = ;
for(i = sum+;i <= ;i ++)
t2 += o[i];
ans = (ans + t1*t2)%MOD;
}
o[a6] ++ ;
}
o[a5] ++ ;
}
o[a4] ++ ;
}
o[a3] ++ ;
}
o[a2] ++;
}
o[a1] ++ ;
}
printf("%I64d\n",ans);
return ;
}

Codeforces Round #157 (Div. 2) D. Little Elephant and Elections(数位DP+枚举)的更多相关文章

  1. Codeforces Round #157 (Div. 1) B. Little Elephant and Elections 数位dp+搜索

    题目链接: http://codeforces.com/problemset/problem/258/B B. Little Elephant and Elections time limit per ...

  2. Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)

    D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...

  3. Codeforces Round #597 (Div. 2) F. Daniel and Spring Cleaning 数位dp

    F. Daniel and Spring Cleaning While doing some spring cleaning, Daniel found an old calculator that ...

  4. Codeforces Round #460 (Div. 2) B Perfect Number(二分+数位dp)

    题目传送门 B. Perfect Number time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  5. Codeforces Round #157 (Div. 2)

    A. Little Elephant and Chess 模拟. B. Little Elephant and Magic Square 枚举左上角,计算其余两个位置的值,在\(3\times 3\) ...

  6. Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  7. Codeforces Round #136 (Div. 1)C. Little Elephant and Shifts multiset

    C. Little Elephant and Shifts Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/pro ...

  8. 字符串(后缀自动机):Codeforces Round #129 (Div. 1) E.Little Elephant and Strings

    E. Little Elephant and Strings time limit per test 3 seconds memory limit per test 256 megabytes inp ...

  9. Codeforces Round #136 (Div. 1) B. Little Elephant and Array

    B. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input ...

随机推荐

  1. 七牛---以一个七牛上传的实例小结下AJAX跨域【转】

    http://blog.csdn.net/netdxy/article/details/50699842 使用七牛过程中,很多用户或多或少遇到跨域的问题,这篇文章主要介绍下跨域的概念来看什么情况下会出 ...

  2. protobuf-net 对象二进制序列化与反序列号(转)

    概述: Protobuf是google开源的一个项目,用户数据序列化反序列化,google声称google的数据通信都是用该序列化方法.它比xml格式要少的多,甚至比二进制数据格式也小的多. Prot ...

  3. Analysis Services OLAP 概述2

    在DW/BI系统中,关系型数据库是存储和管理数据的最佳场所.但是关系数据库本身的智能化程度不够.关系型数据库缺乏如下功能: 丰富的元数据,帮助用户浏览数据和创建查询. 强大的分析计算和函数,在对上下文 ...

  4. WCF学习笔记之消息交换模式

    在WCF通信中,有三种消息交换模式,OneWay(单向模式), Request/Reponse(请求回复模式), Duplex(双工通信模式)这三种通信方式.下面对这三种消息交换模式进行讲解. 1. ...

  5. 关于RTP负载类型及时间戳介绍

    转自:http://www.360doc.com/content/11/1018/13/1016783_157133781.shtml 首 先,看RTP协议包头的格式: 前12个字节在每一个RTP p ...

  6. RTP timestamp与帧率及时钟频率的关系

    转自:http://blog.csdn.net/jasonhwang/article/details/7316128 RTP timestamp是用时钟频率(clock rate)计算而来表示时间的. ...

  7. PMP 第八章 项目质量管理

    1规划质量 2实施质量保证 3实施质量控制 质量成本 1.等级和质量的区别?现代质量管理的重要性,关注图8-2    质量是一些列内在特性满足要求的程度,而等级是对用途相同但技术特性不同的产品或服务的 ...

  8. Java中的wait和sleep

    sleep()和wait() 首先,Java中的多线程是一种抢占式的机制,而不是分时机制.抢占式的机制是有多个线程处于可运行状态,但是只有一个线程在运行. 这种机制决定了,对于同一对象的多线程访问,必 ...

  9. Oracle中“行转列”的实现方式

    在报表的开发当中,难免会遇到行转列的问题. 以Oracle中scott的emp为例,统计各职位的人员在各部门的人数分布情况,就可以用“行转列”: scott的emp的原始数据为: EMPNO ENAM ...

  10. codeforces724-A. Checking the Calendar 日期题

    首先有这样一个显然的事实,那就是每个月的第一天可以是星期x,x可以取遍1~7 因为日期一直在往后退,总有一年能轮到分割线那天,因为本来其实压根就没有月份的划分,月份划分是人为的 而且我们也不知道开始的 ...