题意 n个人顺时针围成一圈玩约瑟夫游戏 每个人手上有一个数val[i] 开始第k个人出队 若val[k] 0 时向左数val[k]个 第m出队的人可以得到m的约数个数个糖果 问得到最多糖果的人是谁
约瑟夫环问题 n比较大 直接模拟会超时 通过线段树可以让每次出队在O(logN)时间内完成 类似上一道插队的题 线段树维护对应区间还有多少个人没出队 那么当我们知道出队的人...
分类:
其他好文 时间:
2015-07-13 22:34:13
阅读次数:
237
题目链接点击打开链接
题目大意:给出n个人的姓名和手里的一个号码,n个人排成一圈,号码有正有负,代表着正向还是反向移动k个位置,比赛从第k个人开始,把被选到的人踢出,问按踢出的顺序中因子数最多的是谁?
建立线段树,把n个人被踢的顺序找到,然后求出n个人中因子数最多的(最小的数)是谁,这里要用到反素数,详看链接点击打开链接
#include
#include
#include
using...
分类:
其他好文 时间:
2015-07-11 12:15:23
阅读次数:
105
Candy
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following...
分类:
其他好文 时间:
2015-06-23 15:34:56
阅读次数:
99
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi...
分类:
其他好文 时间:
2015-06-14 15:04:07
阅读次数:
211
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following req...
分类:
编程语言 时间:
2015-06-03 13:35:47
阅读次数:
176
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following requirements:
Each child must have at least on...
分类:
其他好文 时间:
2015-05-29 18:18:54
阅读次数:
115
Title:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following...
分类:
其他好文 时间:
2015-05-22 15:02:41
阅读次数:
107
题意:你最多可以吃C千克的糖, 有两种糖,每种糖有两个参数,一个为重 w ,一个为欢乐度 h , 如何选择才能拥有最高的欢乐度, 两种糖数量不限。
题解:看了半天题解才理解如何做,
分为两种枚举政策涵盖了所有情况, 时间复杂度为sqrt(c),神奇的暴力
1。如果两种糖中重量最大的超过sqrt(c), 那么该糖最多也只能选择不超过sqrt(c)个, 直接枚举该糖个数,记录最大欢...
分类:
其他好文 时间:
2015-05-21 10:55:18
阅读次数:
195
题目描述:
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following requirements:
Each child must have ...
分类:
其他好文 时间:
2015-05-19 16:37:14
阅读次数:
190
Candy问题:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the followi...
分类:
其他好文 时间:
2015-05-19 00:36:46
阅读次数:
126