最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css

来源:懂视网 责编:小采 时间:2020-11-27 16:00:03
文档

CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css

CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css_WEB-ITnose:Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think
推荐度:
导读CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css_WEB-ITnose:Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think

Roman and Numbers

time limit per test

4 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.

Number x is considered close to number n modulo m, if:

  • it can be obtained by rearranging the digits of number n,
  • it doesn't have any leading zeroes,
  • the remainder after dividing number x by m equals 0.
  • Roman is a good mathematician, but the number of such numbers is too huge for him. So he asks you to help him.

    Input

    The first line contains two integers: n (1?≤?n?

    Output

    In a single line print a single integer ? the number of numbers close to number n modulo m.

    Sample test(s)

    input

    104 2

    output

    input

    223 4

    output

    input

    7067678 8

    output

    47

    Note

    In the first sample the required numbers are: 104, 140, 410.

    In the second sample the required number is 232.


    题意:给出一个数字num和m,问通过重新排列num中的各位数字中有多少个数(mod m)=0,直接枚举全排列肯定不行,可以用状压dp来搞..

    dp[S][k]表示选了num中的S且(mod m)=k的方案种数,初始条件dp[0][0]=1,转移方为dp[i|1<

    #include #include using namespace std;typedef long long ll;ll dp[1<<18][100],c[20];//dp[S][k]表示选了num中的S且(mod m)=k的方案种数int main(int argc, char const *argv[]){	char num[20];	int m;	while(cin>>num>>m) {		memset(dp,0,sizeof dp);		memset(c,0,sizeof c);		dp[0][0]=1;		ll div=1,sz=strlen(num),t=1<

    声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文档

    CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css

    CodeforcesRound#235(Div.2)D.RomanandNumbers(状压dp)_html/css_WEB-ITnose:Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think
    推荐度:
    标签: and html css
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top