common multiple { for(j=1; j +; j + +) {Lcm[i][j]=LCM (I,J); } } while(SCANF ("%d%d%d", n,m,k)! =EOF) { intCnt=0; //because least common multiple m is known, the AI must be his factor. for(i=1; i) { if(m%i==0) num[cnt++]=i; } //Dp[now][i][j]now represents the number of solutions for the current state, and for I, least common multiple J. Recursion k times out the answer. intnow=0; //memset (dp[nom],0,sizeof (dp[nom)); for(
details in the sample and hint below.Sample Input4 2 23) 2 2Sample Output12Test instructionsGive n,m,k, ask K number of and is n, least common multiple for m of case there are severalIdeas:Because least common multiple is m, you can know that these numbers are necessarily m factors, then we just need to select all of these factors, take these factors to the backpack can beDp[i][j][k] indicates that the number of I has been placed, and the case of J, common multiple K has severalBut the problem,
that each row has 1, which is the premise. And to get the answer, we can enumerate I .columnis 0 (total C (m,i) selection), then consider the remaining (m-i) positions of each line, weyou can nowto arbitrarily place the 2^ (m-i), but in order to ensure that each line has 1 to reduce 1, this timefor (2^ (m-i)-1).Then there are n rows, so sum[i]= (2^ (m-i)-1) ^n, and then we're going fromThere are some things out there that areonly column I is all 0 (note that just I is not the only column)so let
/************************************************* author:running_time* Created time:2015/10/28 Wednesday 20:20:09* Fi Le name:h.cpp ************************************************/#include DP (optimized) uvalive 6073 Math Magic
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.