本文出自:http://blog.csdn.net/dr5459 题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4198 题目意思: 给你编号1~n的数,每次从格k个删一个数,会有一个顺序 让你给出最后三个被删除的数 解题思路: 这题很明显就是约瑟夫的变形 假设编号从0~n-1 我们令f[1]=0   表示还剩1个时最后被删掉的…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4140 本来是要昨天来写这学习代码的,然后昨晚寝室又断电了,忍不住在这里吐槽一下,嗯,寝室天天断电. 题意就是输入n,k,m三个数,n个数排成一个圈,第一次删除m,以后每数k个数删除一次,求最后一个被删除的数. 言归正传,以前写过一个链表的约瑟夫问题,但是在这里肯定是会超时的.后来看了些参考…
And Then There Was One UVALive - 3882 Sample Input   Sample Output //设f[i]为(原约瑟夫问题)第i次要删除的标号 #include<cstdio> using namespace std; ; int n,m,k,f[N]; int main(){ &&n){ //f[1]=0; //for(int i=2;i<=n;i++) f[i]=(f[i-1]+k)%i; //int ans=(m-k+f[n…
若干人左对齐站成最多5行,给定每行站多少个,列数从第一排开始往后递减.要求身高从每排从左到右递增(我将题意篡改了便于理解233),每列从前向后递增.每个人身高为1...n(n<=30)中的一个数(互不不同).求可行方案数.(地址点我qwq): 做了lyd书dp这一章的第一题,就不会qwq..果然菜的人还是永远菜啊,注定翻不了身. lyd的书上讲到了dp的方法,不是很理解.后来想通了,发现自己想的时候也想到了这一点转化,但是又很快把他抛弃掉了..冏. 上面所谓的转化就是说,我本来安排人去排列,是无…
Pascal's Travels Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description An n x n game board is populated with integers, one nonnegative integer per square. The goal is to travel along any legitimate pat…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1208 Pascal's Travels Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2795    Accepted Submission(s): 1298 Problem Description An n x n game board…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1176 免费馅饼 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 60927    Accepted Submission(s): 21380 Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径…
Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47657   Accepted: 17949 Description The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n,…
Roman Roulette Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 286    Accepted Submission(s): 105 Problem Description The historian Flavius Josephus relates how, in the Romano-Jewish conflict of…
题目:https://www.luogu.org/problemnew/show/P1996 题意: 约瑟夫环.每次取出第m个,第2m个...... 思路: 链表维护.[感觉很少有用到链表.]非常经典的约瑟夫问题,用链表解决. #include<cstdio> #include<cstdlib> #include<map> #include<set> #include<iostream> #include<cstring> #incl…