Test instructions: Permutation group, the length of the question ring how many kinds
Analysis:
The length of the ring is the least common multiple of each interval length you choose. The total interval length is n, so the question is how many least common multiple of each number of sums equals N.
Status: Dp[i][j] The optimal solution of the first I prime number, the interval length not exceeding J
Transfer: dp[i][j]=dp[i-1][j]+dp[i-1][j-k],k=prim[i]^1,2 ...
This question and the DP of the previous question is difficult to cry me.
Code:
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include < String>using namespace Std;int n;long long dp[300][2000];int prim[300],vis[2000],cnt;void Is_prim () {Cnt=1;memset ( Vis,0,sizeof (VIS)); for (int i=2;i<=1000;i++) {if (!vis[i]) {prim[cnt++]=i;for (int j=i;j<=1000;j+=i) {vis[j]=1;}}}} void DP () {memset (dp,0,sizeof (DP)), for (Int. i=0;i<=1000;i++) dp[0][i]=1;for (int i=1;i<cnt;i++) {for (int j=0;j <=1000;j++) {dp[i][j]=dp[i-1][j];for (int k=prim[i];k<=j;k*=prim[i]) dp[i][j]+=dp[i-1][j-k];}} int main () {Is_prim ();DP(); while (scanf ("%d", &n)!=eof) {printf ("%i64d\n", Dp[cnt-1][n]);}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
! HDU 4345 The ring length of permutation group how many kinds of-DP