hdu 4472 Count(递推即dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472
代码:
#include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> #include <utility> using namespace std; const int maxn = 1055; const int maxe = 1e6+100; const int INF = 0x3f3f3f3f; const int mod = 1e9 +7; int main() { long long dp[maxn]; int n; dp[1] = 1; dp[2] = 1; dp[3] = 2; for(int i=4;i<=1005;i++) { dp[i] = dp[i-1]; for(int j=2;j<=i-1;j++) { if((i-1)%j == 0) { dp[i] += dp[(i-1)/j]; } } } int T = 0; while(cin>>n) { printf("Case %d: %d\n",++T,dp[n]%mod); } }