ACM: 线段树 poj 2886 约瑟夫问题
来源:互联网 发布:mac安装jdk 编辑:程序博客网 时间:2024/06/05 04:57
Description
N children are sitting in a circle to play a game.
The children are numbered from 1 to N in clockwise order.Each of them has a card with a non-zero integer on it in his/herhand. The game starts from the K-th child, who tells all theothers the integer on his card and jumps out of the circle. Theinteger on his card tells the next child to jump out. Let Adenote the integer. If A is positive, the next child will bethe A-th child to the left. If A is negative, thenext child will be the (−A)-th child to the right.
The game lasts until all children have jumped out of the circle.During the game, the p-th child jumping out will getF(p) candies where F(p) is the numberof positive integers that perfectly divide p. Who gets themost candies?
Input
Output
Output one line for each test case containing the name of theluckiest child and the number of candies he/she gets. If tiesoccur, always choose the child who jumps out of the circlefirst.
Sample Input
4 2
Tom 2
Jack 4
Mary -1
Sam 1
Sample Output
Sam 3
题意: 经典的约瑟夫问题, 但是这次第p个出局的人计算获得candy, 就是题目中提出的F(p):
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 500005
struct person
{
}p[MAX];
struct node
{
}pt[MAX*4];
int n, k;
int anti_prime[MAX];
int len, best, count;
int result;
void init()
{
}
void buildTree(int l, int r,int pos)
{
}
void del(int num, int pos,int c)
{
}
int main()
{
//
}
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1177
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 1151 足足想了三…
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 2482 煽情的情书!…
- poj 3321 Apple Tree 线段树
- poj 2182 Lost Cows 线段树
- 【线段树】 POJ 2828 Buy Tickets
- ACM:着色问题 poj 1129
- POj 2379 ACM Rank Table
- 计算机和资料 转载
- ACM: trie树 poj 2513
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 2482 煽情的情书!…
- C++ 友元类
- ACM: 树状数组 poj 1195
- ACM: 树状数组 poj 2155 学习《浅…
- ACM: 树状数组 poj 3321 图论+树状…