随笔分类 - 排列组合
摘要:/*第4场多校联合训练解题报告——详见杭电ACM微博~DressingTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1574 Accepted Submission(s): 670Problem DescriptionWangpeng has N clothes, M pants and K shoes so theoretically he can have N×M×K different combinations o
阅读全文
摘要:/*枚举生成可重集排列*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 2600000int A[maxn];int P[maxn];int sum;void print_p(int n,int *A,int *P,int cur){ int i,j; if(cur==n) { for(i=0; i#include#include#include#include#include#include#includeusi...
阅读全文
摘要:#include #includeusing namespace std;int main(){ int r,n,ans,t; scanf("%d%d",&n,&r); if(n-r<r) r=n-r; ans = n; n=n-1; t=2; while(t<=r) { ans=ans*n/t; n--; t++; } printf("%d\n",ans); return 0;}
阅读全文
摘要:*Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7012 Accepted Submission(s): 4968Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166
阅读全文
摘要:/*排列组合 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1130 Accepted Submission(s): 467Problem Description 有n种物品,并且知道每种物品的数量。要求从中选出m件物品的排列数。例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB","BA"两种。Input 每组输入数据有两行,第一行是二个数n,m(1<=m,n<=10
阅读全文
摘要:Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。Output对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。Sample Input2 1 2Sample Output2 7主要是找规律#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>using namespace std;int main(){ int t,ans,n; scanf(&quo
阅读全文
摘要:/*不容易系列之(4)——考新郎 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12511 Accepted Submission(s): 4740Problem Description 国庆期间,省城HZ刚刚举行了一场盛大的集体婚礼,为了使婚礼进行的丰富一些,司仪临时想出了有一个有意思的节目,叫做"考新郎",具体的操作是这样的:首先,给每位新娘打扮得几乎一模一样,并盖上大大的红盖头随机坐成一排; 然后,让各位新郎寻找
阅读全文
摘要:/*Binomial Showdown Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15798 Accepted: 4839DescriptionIn how many ways can you choose k elements out of n elements, not taking order into account? Write a program to compute this number. InputThe input will contain one or more test cases. Each
阅读全文
摘要:/*Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27679 Accepted: 7638DescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive i
阅读全文
摘要:Happy 2006Time Limit: 3000MSMemory Limit: 65536KTotal Submissions: 6940Accepted: 2192DescriptionTwo positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9...are all relatively prime to 2006. Now your job is easy: for the g.
阅读全文
摘要:AnagramTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 15507Accepted: 6331DescriptionYou are to write a program that has to generate all possible words from a given set of letters. Example: Given the word "abc", your program should - by exploring all different combination of the t
阅读全文
摘要:/*ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4928 Accepted: 2964DescriptionIt is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, t
阅读全文
摘要:Description题目描述: 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。 任务描述: 给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列为第1个排列,即排列1 2 3…n。 比如:n = 3,k=2 给出排列2 3 1,则它的下1个排列为3 1 2,下2个排列为3 2 1,因此答案为3 2 1。 Input第一行是一个正整数m,表示测试数据的个数,下面是m组测试数据,每组测试数据第一行是2个正整数n( 1...
阅读全文
浙公网安备 33010602011771号