![](https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D158/sign=082f215ef9f2b211e02e814bf2806511/e61190ef76c6a7efd60cef0bfffaaf51f3de66f0.jpg)
![](https://gss1.bdstatic.com/-vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D35/sign=60a20bfb4610b912bbc1f0fbc2fd6255/0bd162d9f2d3572cbc6cd09c8b13632763d0c3e0.jpg)
![](https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D359/sign=bba0ba8dfd039245a5b5e70abe95a4a8/83025aafa40f4bfb8383d214024f78f0f736181a.jpg)
![](https://gss1.bdstatic.com/-vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D41/sign=ad985c6f94cad1c8d4bbfd267e3e1176/a08b87d6277f9e2f9ade51481e30e924b999f383.jpg)
![](https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D64/sign=61304071203fb80e08d162d337d12c78/dcc451da81cb39dbd6242b16d1160924aa18308d.jpg)
![](https://gss0.bdstatic.com/-4o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D228/sign=afb836b2d462853596e0d523a8ee76f2/810a19d8bc3eb1350712fbfba71ea8d3fc1f449c.jpg)
![](https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D251/sign=4cc05d0f9f2f07085b052d05d824b865/0b46f21fbe096b633d3211100d338744ebf8ac43.jpg)
![](https://gss3.bdstatic.com/7Po3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D260/sign=00b103410b55b31998f9857373a88286/562c11dfa9ec8a13cc5518a0f603918fa0ecc027.jpg)
![](https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D310/sign=943b3b44960a304e5622a6fbe1c9a7c3/d50735fae6cd7b89f77575c30e2442a7d9330e50.jpg)
![](https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D36/sign=63c5c3714b90f60300b09a413812a5ef/11385343fbf2b2117a54ca0ecb8065380cd78e7c.jpg)
![](https://gss2.bdstatic.com/9fo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D334/sign=894006a98c1001e94a3c120c8c0f7b06/dc54564e9258d1099952e6f2d058ccbf6c814d38.jpg)
![](https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D57/sign=0a8bcd3542a98226bcc12b208b82abf6/37d3d539b6003af3dbc89320342ac65c1038b604.jpg)
![](https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D382/sign=09bf5b4fb90e7bec27da05e91d2fb9fa/d058ccbf6c81800a2966c64eb03533fa838b47ea.jpg)
![](https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D63/sign=5897c9ae9d82d158bf825ab2810a02bc/1f178a82b9014a907f9d09fda8773912b21beecb.jpg)
![](https://gss3.bdstatic.com/7Po3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D308/sign=5bdb4f8ae7cd7b89ed6c3c8337254291/a8773912b31bb05177c5fc68377adab44bede089.jpg)
![](https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D254/sign=ddb6b06348540923ae69647ba658d1dc/c9fcc3cec3fdfc03c242adf8d53f8794a4c226b3.jpg)
![](https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D156/sign=65a94da12e2eb938e86d7ef7e36385fe/6d81800a19d8bc3e807b488a838ba61ea8d3457a.jpg)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cstring> #define N 1001 using namespace std; int C[N][N],n,m; int main() { scanf("%d%d",&n,&m); if(n<m)swap(n,m); for(int i=0;i<=n;i++) C[i][i]=1,C[i][0]=1; for(int i=2;i<=n;i++) for(int j=1;j<=m;j++) C[i][j]=C[i-1][j]+C[i-1][j-1]; printf("%d ",C[n][m]); }
1137 计算系数
2011年NOIP全国联赛提高组
给定一个多项式(ax + by)^k,请求出多项式展开后x^n y^m项的系数。
共一行,包含 5 个整数,分别为a,b,k,n,m,每两个整数之间用一个空格隔开。
输出共 1 行,包含一个整数,表示所求的系数,这个系数可能很大,输出对10007 取模后的结果。
1 1 3 1 2
3
数据范围
对于 30%的数据,有0≤k≤10;
对于 50%的数据,有a = 1,b = 1;
对于 100%的数据,有0≤k≤1,000,0≤n, m≤k,且n + m = k,0≤a,b≤1,000,000。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cstring> #define LL long long #define N 1010 using namespace std; long long C[N][N]; int s,a,b,k,n,m; long long ksm(long long k,long long tmp) { long long a=1; long long b=k; while (tmp!=0) { if (tmp%2==1) a=(a*b)%10007; b=(b*b)%10007; tmp=tmp/2; } return a; } int main() { scanf("%d%d%d%d%d",&a,&b,&k,&n,&m); for (int i=1;i<=k+1;i++) { C[i][i]=1; C[i][1]=1; } for (int i=2;i<=k+1;i++) for (int j=2;j<=i;j++) { C[i][j]=(C[i-1][j]+C[i-1][j-1])%10007; } s=C[k+1][m+1]; s=(s*(ksm(a,n)*ksm(b,m)))%10007; cout<<s; return 0; }
poj 1850
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 9918 | Accepted: 4749 |
Description
The coding system works like this:
• The words are arranged in the increasing order of their length.
• The words with the same length are arranged in lexicographical order (the order from the dictionary).
• We codify these words by their numbering, starting with a, as follows:
a - 1
b - 2
...
z - 26
ab - 27
...
az - 51
bc - 52
...
vwxyz - 83681
...
Specify for a given word if it can be codified according to this coding system. For the affirmative case specify its code.
Input
• The word is maximum 10 letters length
• The English alphabet has 26 characters.
Output
Sample Input
bf
Sample Output
55
题意:
按照字典序的顺序从小写字母 a 开始按顺序给出序列 (序列中都为升序
字符串)
* a - 1
* b - 2
* ...
* z - 26
* ab - 27
* ...
* az - 51
* bc - 52
* ...
* vwxyz - 83681
* 输入字符串由小写字母 a-z 组成字符串为升序,根据字符串输出在字典
里的序列号为多少。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
/* 组合数 题意是查一个字串的字典序排名 先求出长度比它小的,显然是ΣC 26 i(i<len) 然后求出长度等于它却比它小的。具体看代码。 */ #include<iostream> #include<cstdio> #include<cstring> #define N 27 using namespace std; int c[N][N],ans; char str[N]; inline void combination() { for(int i=0;i<=26;i++) for(int j=0;j<=i;j++) if(!j || i==j) c[i][j]=1; else c[i][j]=c[i-1][j-1]+c[i-1][j]; c[0][0]=0; return; } int main() { combination(); while(cin>>str) { ans=0; int len=strlen(str); for(int i=1;i<len;i++) if(str[i]<=str[i-1]) { cout<<"0"<<endl; return 0; } for(int i=1;i<len;i++) ans+=c[26][i];//长度小于它的所有方案 for(int i=0;i<len;i++) { char ch=(!i)?'a':str[i-1]+1;//比上一个大 while(ch<str[i])//比当前这个小 { ans+=c['z'-ch][len-i-1];//长度等于它且排在它前面的所有方案 ch++; } } cout<<++ans<<endl; } return 0; }
codevs 1262
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cstring> #define N 100 using namespace std; int c[N][N],n,ans; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) for(int j=0;j<=i;j++) if(!j || i==j) c[i][j]=1; else c[i][j]=c[i-1][j]+c[i-1][j-1]; printf("%d ",c[n-1][3]); return 0; }
瞬间移动
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1422 Accepted Submission(s):
684
![](http://acm.hdu.edu.cn/data/images/C702-1003-1.jpg)
两个整数n,m(2≤n,m≤100000)
![](https://images2017.cnblogs.com/blog/1000791/201708/1000791-20170824171502105-1873931204.png)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<cstdio> #include<cstring> #define N 200001 #define M 1000000007 #define ll long long using namespace std; ll fac[N]={1,1},inv[N]={1,1},f[N]={1,1}; int n,m; ll C(ll a,ll b) { return fac[a]*inv[b]%M*inv[a-b]%M; } int main() { for(int i=2;i<N;i++) { fac[i]=fac[i-1]*i%M; f[i]=(M-M/i)*f[M%i]%M; inv[i]=inv[i-1]*f[i]%M; } while(~scanf("%d%d",&n,&m)) printf("%lld ",C(m+n-4,m-2)); return 0; }
bzoj4517 排列计数
https://www.cnblogs.com/L-Memory/p/9917967.html
Luogu P2822组合数问题
https://www.cnblogs.com/L-Memory/p/9918229.html