首页 技术 正文
技术 2022年11月8日
0 收藏 314 点赞 1,651 浏览 967 个字

以三个人组队为例,3组合是:C(3,0)=1,3,3,1。还有队长的选择。有

1*0,3*1,3*2,1*3种。

组合数:            1      3        3        1

队长的选择:    0        1        2        3

原本选择数是1*0+3*1+3*2+1*3=12种。现在用另一种方法计算,观察到左右是对称的,因此1的数量,3的数量都是3个,就等于(2^3)*4/2=12种。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
typedef unsigned long long ull;
const lon SZ=,INF=0x7FFFFFFF,mod=;void init()
{}void work()
{}lon pow(lon x,lon n)
{
lon res=,ele=x;
for(;n;)
{
if(n&)
{
res=res*ele%mod;
}
ele=ele*ele%mod;
n/=;
}
return res;
}int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
ull casenum;
cin>>casenum;
//cout<<casenum<<endl;
for(ull time=;time<=casenum;++time)
//for(ull time=1;cin>>n,n;++time)
{
init();
work();
lon n;
cin>>n;
lon res=pow(2LL,n-);
res=res%mod*(n)%mod;
res%=mod;
res+=mod;
res%=mod;
cout<<"Case #"<<time<<": "<<res<<endl;
}
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289