SAC#1 - 組み合わせの数

SAC#1 - 組み合わせの数

タイトルの意味を簡素化\(:\)

でも、パスカルの三角形の行の合計を配置します。

私たちは、パスカルの三角形の行をしていることを知っている\(N-2 ^ \)

そう答えはその\(2 ^ {N-1 } \) それ?はい。

パスカルの三角形ので対称的です。

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define one first
#define two second
#define rint read<int>
#define int long long
#define pb push_back
#define db double
#define ull unsigned long long
#define lowbit(x) ( x & ( - x ) )

using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
       while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
       return f * x ;
    }

int n ;

const int mod = 6662333 ;

inline int quick (int a , int p) {
    int res = 1 ;
    while ( p ) {
        if ( p & 1 ) res = ( res * a ) % mod ;
        a = ( a * a ) % mod ; p >>= 1 ;
    }
    return res ;
}

signed main (int argc , char * argv[]) {
    n = rint () ;
    printf ("%lld\n" , quick ( 2ll , n - 1 ) ) ;
    system ("pause") ; return 0 ;
}

おすすめ

転載: www.cnblogs.com/Equinox-Flower/p/11756648.html