[POJ1012]Joseph】的更多相关文章

Joseph Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 493  Solved: 311 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, standing in circle e…
  Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 50596   Accepted: 19239 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, stan…
http://poj.org/problem?id=1012 (题目链接) 半年前的考试题..任然清晰的记得那次差10分就AK... 题意 约瑟夫环,有前k个好人,后k个坏人,要求使得后k个坏人先死的最小m. Solution 很水的约瑟夫问题..半年前还是暴力模拟+打表..醉了. 无论是用链表实现还是用数组实现都有一个共同点:要模拟整个游戏过程,不仅程序写起来比较烦,而且时间复杂度高达O(nm),当n,m非常大(例如上百万,上千万)的时候,几乎是没有办法在短时间内出结果的.我们注意到原问题仅仅…
package Joseph;//约瑟夫环,m个人围成一圈.从第K个人开始报数,报道m数时,那个人出列,以此得到出列序列//例如1,2,3,4.从2开始报数,报到3剔除,顺序为4,3,1,2public class Joseph{ class node//结点类 {private int number;  private node next;  node(int num,node next){   this.number=num;   this.next=next;  } } private n…
Joseph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1512    Accepted Submission(s): 948 Problem Description   The Joseph's problem is notoriously known. For those who are not familiar with th…
题目:改进的Joseph环.一圈人报数,报数上限依次为3,7,11,19,循环进行,直到所有人出列完毕. 思路:双向循环链表模拟. 代码: #include <cstdio> #include <cstdlib> #define N 20 typedef struct node { int id; struct node *next; struct node *pre; }Node, *pNode; //双向循环链表的构建 pNode RingConstruct (int n) {…
Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44650   Accepted: 16837 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,…
Joseph Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 52097   Accepted: 19838 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,…
Joseph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2240    Accepted Submission(s): 1361 Problem Description The Joseph's problem is notoriously known. For those who are not familiar with the…
题意: 给出n, k,求 分析: 假设,则k mod (i+1) = k - (i+1)*p = k - i*p - p = k mod i - p 则对于某个区间,i∈[l, r],k/i的整数部分p相同,则其余数成等差数列,公差为-p 然后我想到了做莫比乌斯反演时候有个分块加速,在区间[i, n / (n / i)],n/i的整数部分相同,于是有了这份代码. #include <cstdio> #include <algorithm> using namespace std;…