zoukankan      html  css  js  c++  java
  • 洛谷P3414 SAC#1

    P3414 SAC#1 - 组合数

    题目背景

    本题由世界上最蒟蒻最辣鸡最撒比的SOL提供。

    寂月城网站是完美信息教室的官网。地址:http://191.101.11.174/mgzd 。

    题目描述

    辣鸡蒟蒻SOL是一个傻逼,他居然觉得数很萌!

    今天他萌上了组合数。现在他很想知道simga(C(n,i))是多少;其中C是组合数(即C(n,i)表示n个物品无顺序选取i个的方案数),i取从0到n所有偶数。

    由于答案可能很大,请输出答案对6662333的余数。

    输入输出格式

    输入格式:

    输入仅包含一个整数n。

    输出格式:

    输出一个整数,即为答案。

    输入输出样例

    输入样例#1:
    3
    输出样例#1:
    4

    说明

    对于20%的数据,n <= 20;

    对于50%的数据,n <= 1000;

    对于100%的数据,n <= 1 000 000 000 000 000 000 (10^18)

    /*
        杨辉三角第n行的和为2^n
        偶数项即为2^(n-1) 
    */
    #include<iostream>
    #include<cstdio>
    #define mod 6662333
    using namespace std;
    long long n;
    long long mul(long long a,long long b){
        long long res=0;
        while(b){
            if(b&1)res=(res+a)%mod;
            a=(a+a)%mod;
            b>>=1;
        }
        return res;
    }
    long long pow(long long a,long long b){
        long long res=1;
        while(b){
            if(b&1)res=mul(res,a)%mod;
            a=mul(a,a)%mod;
            b>>=1;
        }
        return res;
    }
    int main(){
        cin>>n;
        cout<<pow(2,n-1);
    }
  • 相关阅读:
    [转] Foobar2000 DSP音效外挂元件-Part4
    谷歌三件套
    Android 线刷小白教程
    nginx负载均衡
    HTTPS证书
    防火墙iptables
    LNMP架构部署
    tomcat部署
    shell编程
    HTTP协议
  • 原文地址:https://www.cnblogs.com/thmyl/p/7573896.html
Copyright © 2011-2022 走看看