Codeforces Round #235 (Div. 2) ----D. Roman and Numbers
来源:互联网 发布:初中题库软件 编辑:程序博客网 时间:2024/05/16 06:40
dp.....
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #include<iostream>#include<algorithm>#include<queue>#include<vector>using namespace std;#define ll __int64#define inf 0x3f3f3f3f#define N 1001000char ch[20];ll dp[1<<18][110];int c[20],v[20];int main(){int i,j,k,l,m;cin>>ch>>m;int len=strlen(ch);for(i=0;i<len;i++)c[i]=ch[i]-'0';int cnt=(1<<len);dp[0][0]=1;for(i=0;i<cnt;i++){for(j=0;j<m;j++){memset(v,0,sizeof(v));for(k=0;k<len;k++){if(i==0 && c[k]==0) continue;if(v[c[k]]) continue;if((i>>k)&1) continue;dp[i+(1<<k)][(j*10+c[k])%m]+=dp[i][j];v[c[k]]=1;}}}cout<<dp[cnt-1][0]<<endl;//system("pause");}
0 0
- Codeforces Round #235 (Div. 2) ----D. Roman and Numbers
- Codeforces Round #235 (Div. 2) D. Roman and Numbers
- Codeforces Round #235 (Div. 2) D Roman and Numbers(状态DP)
- Codeforces Round #235 (Div. 2) D. Roman and Numbers 解题报告(状态压缩)
- Codeforces Round #235 (Div. 2) / 410D Roman and Numbers (带有整除性质的数位DP)
- Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(状压dp)
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(状态压缩DP)
- codeforces #235 D. Roman and Numbers 题解
- Codeforces Round #257 (Div. 1) D. Jzzhu and Numbers
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers 爆搜+剪枝
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- CodeForces 401D Roman and Numbers
- codeforces 401D Roman and Numbers
- 解题报告:Codeforces Round #432 (Div. 2) D. Arpa and a list of numbers 暴力
- Codeforces Round #432 (Div. 2) D 850B Arpa and a list of numbers(gcd 枚举)
- Codeforces 851D Arpa and a list of numbers Round #432 (Div. 2
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Easyui datagrid detailview使用简介
- FlashFXP与虚拟机VMware进行文件传输设置
- Mac OSX下安装使用定理证明器Z3
- 阿里腾讯参与
- sql面试题
- Codeforces Round #235 (Div. 2) ----D. Roman and Numbers
- 多线程服务器的典型适用场合
- android中实现sqlite打包到APK发布
- 一段代码
- 【STL】 map
- 多线程服务器的常用编程模型
- Gstreamer框架中使用gst-launch进行流媒体播放
- Java华丽转身 —— GUI编程宝典
- 适配ios7时使用edgesForExtendedLayout遇到的黑色背景问题