• 母函数--例题


    题意:http://acm.hdu.edu.cn/showproblem.php?pid=2082

      1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
      2 #include <cstdio>//sprintf islower isupper
      3 #include <cstdlib>//malloc  exit strcat itoa system("cls")
      4 #include <iostream>//pair
      5 #include <fstream>//freopen("C:\Users\13606\Desktop\Input.txt","r",stdin);
      6 #include <bitset>
      7 //#include <map>
      8 //#include<unordered_map>
      9 #include <vector>
     10 #include <stack>
     11 #include <set>
     12 #include <string.h>//strstr substr
     13 #include <string>
     14 #include <time.h>// srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
     15 #include <cmath>
     16 #include <deque>
     17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
     18 #include <vector>//emplace_back
     19 //#include <math.h>
     20 #include <cassert>
     21 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
     22 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
     23 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
     24 //******************
     25 int abss(int a);
     26 int lowbit(int n);
     27 int Del_bit_1(int n);
     28 int maxx(int a,int b);
     29 int minn(int a,int b);
     30 double fabss(double a);
     31 void swapp(int &a,int &b);
     32 clock_t __STRAT,__END;
     33 double __TOTALTIME;
     34 void _MS(){__STRAT=clock();}
     35 void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
     36 //***********************
     37 #define rint register int
     38 #define fo(a,b,c) for(rint a=b;a<=c;++a)
     39 #define fr(a,b,c) for(rint a=b;a>=c;--a)
     40 #define mem(a,b) memset(a,b,sizeof(a))
     41 #define pr printf
     42 #define sc scanf
     43 #define ls rt<<1
     44 #define rs rt<<1|1
     45 typedef pair<int,int> PII;
     46 typedef vector<int> VI;
     47 typedef long long ll;
     48 const double E=2.718281828;
     49 const double PI=acos(-1.0);
     50 const ll INF=(1LL<<60);
     51 const int inf=(1<<30);
     52 const double ESP=1e-9;
     53 const int mod=(int)1e9+7;
     54 const int N=(int)1e6+10;
     55 
     56 int a[60],b[60];
     57 int num[60];
     58 
     59 void solve()
     60 {
     61     mem(a,0);
     62     mem(b,0);
     63     for(int i=1;i<=26;++i)
     64     {
     65         int n;
     66         sc("%d",&n);
     67         num[i]=n;
     68     }
     69     bool f=0;
     70     for(int i=1;i<=26;++i)
     71     {
     72         int sz=num[i]+1;
     73         for(int j=0;j<sz;++j)
     74         {
     75             if(!f)b[j]=1;
     76             else
     77             {
     78                 for(int k=0;k<=50;++k)
     79                 {
     80                     if(k+j*i<=50)
     81                         b[j*i+k]+=a[k];
     82                 }
     83             }
     84         }
     85         fo(j,0,59)a[j]=b[j];
     86         mem(b,0);
     87         f=1;
     88     }
     89     ll ans=0;
     90     fo(i,1,50)
     91         ans+=a[i];
     92     pr("%lld
    ",ans);
     93 }
     94 
     95 int main()
     96 {
     97     int T;
     98     sc("%d",&T);
     99     while(T--)solve();
    100     return 0;
    101 }
    102 
    103 /**************************************************************************************/
    104 
    105 int maxx(int a,int b)
    106 {
    107     return a>b?a:b;
    108 }
    109 
    110 void swapp(int &a,int &b)
    111 {
    112     a^=b^=a^=b;
    113 }
    114 
    115 int lowbit(int n)
    116 {
    117     return n&(-n);
    118 }
    119 
    120 int Del_bit_1(int n)
    121 {
    122     return n&(n-1);
    123 }
    124 
    125 int abss(int a)
    126 {
    127     return a>0?a:-a;
    128 }
    129 
    130 double fabss(double a)
    131 {
    132     return a>0?a:-a;
    133 }
    134 
    135 int minn(int a,int b)
    136 {
    137     return a<b?a:b;
    138 }
  • 相关阅读:
    ora.vip 1 ONLINE INTERMEDIAT
    SQL Tuning Health-Check Script (SQLHC) (文档 ID 1366133.1)
    ORA-27140: attach to post/wait facility failed
    RU/RUR的安装
    dbms_profiler
    ignite affinity key 并置 究竟是个啥?
    【Study】 TCP/IP协议 -- 计算机网络之应用层篇(04)
    【Study】 TCP/IP协议 -- 计算机网络之传输层篇(03)
    【Study】 TCP/IP协议 -- 计算机网络之网络篇(02)
    【Study】 TCP/IP协议 -- 计算机网络概述(01)
  • 原文地址:https://www.cnblogs.com/--HPY-7m/p/11780624.html
Copyright © 2020-2023  润新知