随笔分类 -  全排列问题

摘要:#include <stdio.h>#define MAX 100int len, sum;char list[MAX];static int perm(int k, int m);static int swap(int i, int j);int main(){ scanf("%s",list); len = strlen(list); sum = perm(0, len-1);//not include '/n' printf("sum = %d/n", sum); return 0;}static int perm(in 阅读全文

posted @ 2010-12-20 19:43 yming0221 阅读(156) 评论(0) 推荐(0)

摘要:Backward Digit SumsTime Limit:1000MSMemory Limit:65536KDescriptionFJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They repeat this until only a sing 阅读全文

posted @ 2010-12-19 12:53 yming0221 阅读(155) 评论(0) 推荐(0)

摘要:第一次用G++提交TLE,第二次用C++ 460ms水过!标记排列Time Limit:1000MSMemory Limit:30000KTotal Submissions:9419Accepted:4168Description题目描述:大家知道,给出正整数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 阅读全文

posted @ 2010-12-18 19:25 yming0221 阅读(130) 评论(0) 推荐(0)

摘要:本来想用c实现,可是还没来得及细细研究,这里用STL中的next_permutation水过标记一下,以后自己C实现题目地址http://poj.org/problem?id=1731OrdersTime Limit:1000MSMemory Limit:10000KDescriptionThe stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are st 阅读全文

posted @ 2010-12-17 14:58 yming0221 阅读(119) 评论(0) 推荐(0)

导航