zoukankan      html  css  js  c++  java
  • SAC#1

    SAC#1 - 组合数

    题意简化 (:)

    对杨辉三角的某一行的偶数位置求和.

    我们知道,杨辉三角的某一行和是 (2^n).

    那么答案是否就是 (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
    " , quick ( 2ll , n - 1 ) ) ;
        system ("pause") ; return 0 ;
    }
    
  • 相关阅读:
    IIS 安装 pydio
    Windows环境配置Apache+Mysql+PHP
    Azure 云平台用 SQOOP 将 SQL server 2012 数据表导入 HIVE / HBASE
    PHP 启动 cURL模块以及启动失败的解决方案
    NodeJS 各websocket框架性能分析
    使用AndroidStudio编译NDK的方法及错误解决方案
    Ubuntu 系统下 mongodb 安装和配置
    Ubuntu安装nodeJS
    node.js应用Redis数据库
    Android平台相机接口的应用
  • 原文地址:https://www.cnblogs.com/Equinox-Flower/p/11756648.html
Copyright © 2011-2022 走看看