zoukankan      html  css  js  c++  java
  • CodeM 2018 决赛

    A 大力推一下式子 n * sigma i from 2 to n+1 ( C(n-1, i-2) * (i-2)! * (2n-i)! / 2^(n+1-i) ) 就没有然后了 

      1 /* ***********************************************
      2 Author        :BPM136
      3 Created Time  :2018/7/27 10:39:22
      4 File Name     :A.cpp
      5 ************************************************ */
      6 
      7 #include<iostream>
      8 #include<cstdio>
      9 #include<algorithm>
     10 #include<cstdlib>
     11 #include<cmath>
     12 #include<cstring>
     13 #include<iomanip>
     14 #include<bitset>
     15 #include<queue>
     16 #include<ctime>
     17 #include<set>
     18 #include<map>
     19 #include<vector>
     20 #include<cassert>
     21 #include<functional>
     22 #define pb push_back
     23 #define popb pop_back
     24 #define MID ((l+r)>>1)
     25 #define LSON (k<<1)
     26 #define RSON (k<<1|1)
     27 #define get(a,i) ((a)&(1<<(i-1)))
     28 #define PAU putchar(32)
     29 #define ENT putchar(10)
     30 #define clr(a,b) memset(a,b,sizeof(a))
     31 #define rep(_i,_a,_b) for(int _i=(_a);_i<=(_b);_i++)
     32 #define down(_i,_a,_b) for(int _i=(_a);_i>=(_b);_i--)
     33 #define FOR(_i,_b) for(int _i=1;_i<=(_b);_i++)
     34 #define efo(_i,_a) for(int _i=last[(_a)];_i!=0;_i=e[_i].next)
     35 #define Remax(a,b) if(b>a) a=b;
     36 #define Remin(a,b) if(b<a) a=b;
     37 #define filein(x) freopen(#x".in","r",stdin)
     38 #define fileout(x) freopen(#x".out","w",stdout)
     39 #define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
     40 #define mkd(x) freopen(#x".in","w",stdout);
     41 #define setlargestack(x) int _SIZE=x<<20;char *_PPP=(char*)malloc(size)+_SIZE;__asm__("movl %0, %%esp
    " :: "r"(_PPP));
     42 #define END system("pause")
     43 #define read2(a,b) read(a),read(b)
     44 #define read3(a,b,c) read(a),read(b),read(c)
     45 #define readg(_x1,_y1,_x2,_y2) read(_x1),read(_y1),read(_x2),read(_y2)
     46 using namespace std;
     47 
     48 typedef long long ll;
     49 typedef double DB;
     50 typedef long double LD;
     51 typedef unsigned int  UI;
     52 typedef unsigned long long ULL;
     53 typedef vector<int> VI;
     54 typedef set<int> SI;
     55 typedef set<int , greater<int> > SIG;
     56 typedef map<int, int > MII;
     57 typedef map<int, int, greater<int> > MIIG;
     58 
     59 namespace fastIO{  
     60     #define BUF_SIZE 100000  
     61     #define OUT_SIZE 100000  
     62     //fread->read  
     63     bool IOerror=0;  
     64     inline char nc(){  
     65         static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;  
     66         if (p1==pend){  
     67             p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);  
     68             if (pend==p1){IOerror=1;return -1;}  
     69             //{printf("IO error!
    ");system("pause");for (;;);exit(0);}  
     70         }  
     71         return *p1++;  
     72     }  
     73     inline bool blank(char ch){return ch==32||ch==10||ch==13||ch==9;}  
     74     inline bool enter(char ch){return ch==10||ch==13;}
     75     inline void read(int &x){  
     76         bool sign=0; char ch=nc(); x=0;  
     77         for (;blank(ch);ch=nc());  
     78         if (IOerror)return;  
     79         if (ch==45)sign=1,ch=nc();  
     80         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
     81         if (sign)x=-x;  
     82     }  
     83     inline void read(ll &x){  
     84         bool sign=0; char ch=nc(); x=0;  
     85         for (;blank(ch);ch=nc());  
     86         if (IOerror)return;  
     87         if (ch==45)sign=1,ch=nc();  
     88         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
     89         if (sign)x=-x;  
     90     }  
     91     inline void read(double &x){  
     92         bool sign=0; char ch=nc(); x=0;  
     93         for (;blank(ch);ch=nc());  
     94         if (IOerror)return;  
     95         if (ch==45)sign=1,ch=nc();  
     96         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
     97         if (ch==46){  
     98             double tmp=1; ch=nc();  
     99             for (;ch>=48&&ch<=57;ch=nc())tmp/=10.0,x+=tmp*(ch-48);  
    100         }  
    101         if (sign)x=-x;  
    102     }  
    103     inline void read(char *s){  
    104         char ch=nc();  
    105         for (;blank(ch);ch=nc());  
    106         if (IOerror)return;  
    107         for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;  
    108         *s=0;  
    109     }  
    110     inline void read(char *s,bool f) {
    111         char ch=nc();
    112         for (;blank(ch);ch=nc());
    113         if(IOerror)return;
    114         for(;!enter(ch)&&!IOerror;ch=nc())*s++=ch;
    115         *s=0;
    116     }
    117     inline void read(char &c){  
    118         for (c=nc();blank(c);c=nc());  
    119         if (IOerror){c=-1;return;}  
    120     } 
    121 #undef OUT_SIZE  
    122 #undef BUF_SIZE  
    123 }; using namespace fastIO;
    124 
    125 const int N = 2000005;
    126 const ll MOD = 998244353;
    127 
    128 ll inv[N];
    129 ll fac[N];
    130 ll fac_inv[N];
    131 ll bit2_inv[N];
    132 
    133 ll C(int n,int m) {
    134     return fac[n]*fac_inv[m]%MOD*fac_inv[n-m]%MOD;
    135 }
    136 
    137 int main() {
    138     inv[0]=fac[0]=1; inv[1]=1;
    139     rep(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
    140     rep(i,2,N-1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
    141     fac_inv[0]=1; rep(i,1,N-1) fac_inv[i]=fac_inv[i-1]*inv[i]%MOD;
    142     bit2_inv[0]=1; rep(i,1,N-1) bit2_inv[i]=bit2_inv[i-1]*inv[2]%MOD;
    143     ll n;
    144     cin>>n;
    145     ll ans=0;
    146     rep(i,2,n+1) {
    147         ans+=C(n-1,i-2) * fac[i-2] % MOD
    148             *fac[2*n-i] % MOD * bit2_inv[n+1-i] % MOD;
    149         ans%=MOD;
    150     }
    151     cout<<ans*n%MOD<<endl;
    152     return 0;
    153 }
    View Code
  • 相关阅读:
    IT职业选择与定位
    零碎时间应该拿来做什么
    编程漫谈(七):意义与自由
    第一次项目发布的心得体会
    入职一月的一点感想
    职业发展思考(一)
    健康先行: 每天锻炼一小时!!!
    2012, 软件职场之旅启程
    程序员的成长之路
    计算机学习方法
  • 原文地址:https://www.cnblogs.com/MyGirlfriends/p/9380812.html
Copyright © 2011-2022 走看看