2012 Asia Chengdu Regional Contest
Browsing History http://acm.hdu.edu.cn/showproblem.php?pid=4464
签到
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 char a[128]; 5 int main(){ 6 int n,cas=1; 7 while(~scanf("%d",&n)){ 8 int ans=0; 9 while(n--){ 10 scanf("%s",a); 11 int sum=0; 12 for(int i=0;a[i];i++){ 13 sum+=a[i]; 14 } 15 ans=max(ans,sum); 16 } 17 printf("Case %d: %d\n",cas++,ans); 18 } 19 return 0; 20 }
Count http://acm.hdu.edu.cn/showproblem.php?pid=4472
dp i 表示个数为i的种类数,它的第二层可以有很多种情况 只要能整除 这是记忆化搜索的写法。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<cstring> 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 const int M=1024; 5 const int mod=1e9+7; 6 int dp[M]; 7 int dfs(int n){ 8 if(~dp[n]) return dp[n]; 9 dp[n]=0; 10 for(int i=1;i<=n;i++){ 11 if((n-1)%i==0){ 12 dp[n]+=dfs((n-1)/i); 13 dp[n]%=mod; 14 } 15 } 16 return dp[n]; 17 } 18 int main(){ 19 mt(dp,-1); 20 dp[0]=1; 21 for(int i=1;i<M;i++){ 22 dp[i]=dfs(i); 23 } 24 int n,cas=1; 25 while(~scanf("%d",&n)){ 26 printf("Case %d: %d\n",cas++,dp[n]); 27 } 28 return 0; 29 }
人人为我写法
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 const int M=1024; 3 const int mod=1e9+7; 4 int dp[M]; 5 int main(){ 6 dp[0]=1; 7 for(int i=1;i<M;i++){ 8 dp[i]=0; 9 for(int j=1;j<=i;j++){ 10 if((i-1)%j==0){ 11 dp[i]+=dp[(i-1)/j]; 12 dp[i]%=mod; 13 } 14 } 15 } 16 int n,cas=1; 17 while(~scanf("%d",&n)){ 18 printf("Case %d: %d\n",cas++,dp[n]); 19 } 20 return 0; 21 }
我为人人写法
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<cstring> 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 const int M=1024; 5 const int mod=1e9+7; 6 int dp[M]; 7 int main(){ 8 mt(dp,0); 9 dp[1]=1; 10 for(int i=1;i<M;i++){ 11 for(int j=1;(j*i+1)<M;j++){ 12 dp[j*i+1]+=dp[i]; 13 dp[j*i+1]%=mod; 14 } 15 } 16 int n,cas=1; 17 while(~scanf("%d",&n)){ 18 printf("Case %d: %d\n",cas++,dp[n]); 19 } 20 return 0; 21 }
end