以为是组合,后来看着像数位dp,又不知道怎么让它不重复用。。然后就没思路 了。

其实状压就可以了 状压是可以确定一个数的使用顺序的 利用01也可以确定所有的数的使用以及不重复

dp[i+1《《e][(j*10+p[e])%m]+=dp[i][j]; 排下序去掉重复的 或者最后除去每个数出现的次数

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL dp[<<][];
int o[];
int main()
{
LL n;
int m,i,j,a;
while(cin>>n>>m)
{
memset(dp,,sizeof(dp));
LL x = n;
int g = ;
while(x)
{
o[g++] = x%;
x/=;
}
sort(o,o+g);
int pp= - ;
for(i = ; i < g ;i++)
if(o[i]!=pp&&o[i]!=)
{
dp[<<i][o[i]%m] = ;
pp = o[i];
}
//dp[0][0] = 1;
//for(a = 2; a <= g ; a++)
//{
for(i = ;i < (<<g) ; i++)
{
for(j = ; j < m ;j++)
{
if(dp[i][j])
{
int pre = -;
for(int e = ; e < g ;e++)
{
if(o[e]==pre) continue;
if(i&(<<e)) continue;
if(i==&&o[e]==) continue;
dp[i+(<<e)][(j*+o[e])%m]+=dp[i][j];
pre = o[e];
} }
}
}
// }
cout<<dp[(<<g)-][]<<endl;
}
return ;
}

Codeforces Round #235 (Div. 2) D (dp)的更多相关文章

  1. Codeforces Round #235 (Div. 2) D. Roman and Numbers(如压力dp)

    Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard i ...

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

    题目链接: http://codeforces.com/problemset/problem/401/D D. Roman and Numbers time limit per test4 secon ...

  3. 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 ...

  4. 严格递增类的dp Codeforces Round #371 (Div. 1) C dp

    http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型, ...

  5. 很好的一个dp题目 Codeforces Round #326 (Div. 2) D dp

    http://codeforces.com/contest/588/problem/D 感觉吧,这道题让我做,我应该是不会做的... 题目大意:给出n,L,K.表示数组的长度为n,数组b的长度为L,定 ...

  6. Codeforces Round #548 (Div. 2) C dp or 排列组合

    https://codeforces.com/contest/1139/problem/C 题意 一颗有n个点的树,需要挑选出k个点组成序列(可重复),按照序列的顺序遍历树,假如经过黑色的边,那么这个 ...

  7. Codeforces Round #536 (Div. 2) E dp + set

    https://codeforces.com/contest/1106/problem/E 题意 一共有k个红包,每个红包在\([s_i,t_i]\)时间可以领取,假如领取了第i个红包,那么在\(d_ ...

  8. Codeforces Round #541 (Div. 2) G dp + 思维 + 单调栈 or 链表 (连锁反应)

    https://codeforces.com/contest/1131/problem/G 题意 给你一排m个的骨牌(m<=1e7),每块之间相距1,每块高h[i],推倒代价c[i],假如\(a ...

  9. Codeforces Round #543 (Div. 2) F dp + 二分 + 字符串哈希

    https://codeforces.com/contest/1121/problem/F 题意 给你一个有n(<=5000)个字符的串,有两种压缩字符的方法: 1. 压缩单一字符,代价为a 2 ...

随机推荐

  1. hdu1873 看病要排队(结构体优先队列)

    看病要排队 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  2. 添加 XML内Rows数据

    public static void addItemToXml(string method,string firstKey,string id,string checkName,string refV ...

  3. ssh配置无password登录

    前提.机器A,B,均为RedHat Linux操作系统,均实用户user 1.以usernameuser登录,在A机器上运行 ssh-keygen -t rsa 一路回车.不须要输入password ...

  4. DBscan算法及其Python实现

    DBSCAN简介: 1.简介 DBSCAN 算法是一种基于密度的空间聚类算法.该算法利用基于密度的聚类的概念,即要求聚类空间中的一定区域内所包含对象(点或其它空间对象)的数目不小于某一给定阀值.DBS ...

  5. 下载Youku视频观看

    所需工具: 1.chorme内核浏览器,如Chorme.Firefox等等 2.vlc视频播放器 准备工作完成,开始工作 1.打开优酷的随便一个视频 2.按下F12选择Network(网络)选择Med ...

  6. 我的Android进阶之旅------&gt;Android编译错误java.util.zip.ZipException: duplicate entry的解决方法

    今天在Android Studio中把另外一个项目引入当前项目,编译的时候出现了java.util.zip.ZipException: duplicate entry错误. 错误例如以下所看到的: F ...

  7. 2016/3/30 租房子 ①建立租房子的增、删、改php页面 ②多条件查询 ③全选时 各部分全选中 任意checkbox不选中 全选checkbox不选中

    字符串的另一种写法:<<<AAAA; 后两个AA回车要求顶格  不然报错 例子: <!DOCTYPE html> <html lang="en" ...

  8. javaScript复制粘贴

    1.clipboard.js 实现了纯 JavaScript (无 Flash)的浏览器内容复制到系统剪贴板的功能.可以在浏览器和 Node 环境中使用.支持 Chrome 42+.Firefox 4 ...

  9. 如何将Eclipse中的项目迁移到Android Studio中

    如果你之前有用Eclipse做过安卓开发,现在想要把Eclipse中的项目导入到Android Studio的环境中,那么首先要做的是生成Build Gradle的文件.因为Android Studi ...

  10. 本地锁、redis分布式锁、zk分布式锁

    本地锁.redis分布式锁.zk分布式锁 https://www.cnblogs.com/yjq-code/p/dotnetlock.html 为什么要用锁? 大型站点在高并发的情况下,为了保持数据最 ...