2012年5月1日
摘要: 转自他人文章 非原创#include <stdio.h> #include <string.h> #include <list> using namespace std; void convert(char *a,list<int> &a1) {/*转换函数*/ a1.clear(); int len=strlen(a); int i; for(i=0;i<len;i++) a1.push_back(a[i]-'0'); while(*a1.begin()==0) a1.pop_front(); } void pri 阅读全文
posted @ 2012-05-01 11:34 夜-> 阅读(562) 评论(0) 推荐(0) 编辑
摘要: 转自他人文章 非原创问题描述:n个人(编号1~n),从1开始报数,报到m的退出,剩下的人继续从1开始报数. 求胜利者的编号我们知道第一个人(编号一定是(m-1) mod n+1) 出列之后,剩下的n-1个人组成了一个新的约瑟夫环(以编号为k=m mod n+1的人开始):k k+1 k+2 ... n-1, n, 1, 2, ... k-2并且从k开始报1现在我们把他们的编号做一下转换:k --> 1k+1 --> 2k+2 --> 3......k-2 --> n-1变换后就完完全全成为了(n-1)个人报数的子问题,假如我们知道这个子问题的解:例如x是最终的胜利者,那 阅读全文
posted @ 2012-05-01 11:33 夜-> 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 常规求法会超时 发现了一个规律 证明的话 亲 你自己想吧http://poj.org/showsource?solution_id=10139647#include <iostream>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <cstdio>using namespace std;//const int N=99000001;int k[30];int main(){ int n,m; char c; f 阅读全文
posted @ 2012-05-01 11:29 夜-> 阅读(244) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3281#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <queue>#include <algorithm>using namespace std;const int MAX=0x7fffffff;const int N=510;int path[N][N];int l[N];int n,f,d;int Bfs(){ 阅读全文
posted @ 2012-05-01 09:53 夜-> 阅读(161) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示