标签:结果 image htm put content namespace sam name mem
对于 20%的数据,满足 N≤10;
对于 40%的数据,满足 N≤18;
对于 70%的数据,满足 N≤550;
对于 100%的数据,满足 3≤N≤4200,P≤109
我是不会写题解啦?
我当然不懂得写题解啦。。
供上一位大佬的题解。。
1 /************************************************************** 2 Problem: 1925 3 User: ZYBGMZL 4 Language: C++ 5 Result: Accepted 6 Time:228 ms 7 Memory:1320 kb 8 ****************************************************************/ 9 10 #include<cstdio> 11 #include<cstring> 12 #include<iostream> 13 using namespace std; 14 15 const int maxn=4205; 16 17 int n,mod,ans=0,s; 18 int dp[2][maxn]; 19 bool pos=1; 20 21 int main(){ 22 scanf("%d%d",&n,&mod); 23 dp[1][1]=1; 24 for(int i=2;i<=n;i++){ 25 pos^=1; 26 memset(dp[pos],0,sizeof dp[pos]); 27 s=0; 28 for(int j=i-1;j;j--){ 29 s=(s+dp[pos^1][i-j])%mod; 30 dp[pos][j]=s; 31 } 32 } 33 for(int i=1;i<=n;i++) 34 ans=(ans+dp[pos][i])%mod; 35 printf("%d\n",(ans<<1)%mod); 36 return 0; 37 }
标签:结果 image htm put content namespace sam name mem
原文地址:http://www.cnblogs.com/ZYBGMZL/p/7296089.html