Some simple ideas generating function (HDU2110)

// Problems Solved generating function
 // n-kinds of goods, each having a Wi, combined into a total value of how many combination regimen
 // converts compositions problem Multiplication (important) (Orz) on power series
 / / #include <the iostream>
 // #include <cstdio>
 // #include <CString>
 // the using namespace STD;
 // int n-, A [105], B [105], m, S [10010], T [ 10010];
 // int main ()
 // {
 //      the while (~ Scanf ( "% D", & n-), n-)
 //      {
 //          m = 0;
 //          for (int I = 0; I <n- ; I ++)
 //          {
 //              Scanf ( "% D% D", & A [I], B & [I]);
 //              m + = (A [I] * B [I]);
//         }
//         if(m%3!=0)
//         {
//             printf("sorry\n");
//             continue;
//         }
//         memset(s,0,sizeof(s));
//         memset(t,0,sizeof(t));
//         m/=3;
//         for(int i=0; i<=b[0]&&i*a[0]<=m; i++)
//         {
//             s[i*a[0]]=1;
//         }
//         for(int i=1; i<n; i++)
//         {
//             for(int j=0; j<=m; j++)
//                 for(int k=0; k<=b[i]&&k*a[i]+j<=m; k++)
//                 {
//                     t[k*a[i]+j]+=s[j];
//                     t[k*a[i]+j]%=10000;
//                 }
//                 for(int j=0; j<=m; j++)
//                 {
//                     s[j]=t[j];
//                     t[j]=0;
//                 }
//         }
//         if(s[m]!=0)
//         {
//             printf("%d\n",s[m]);
//         }
//         else printf("sorry\n");
//     }
//     return 0;
// }

 

Guess you like

Origin www.cnblogs.com/newstartCY/p/11563395.html