Ball CodeForces - 12D (线段树)
题目链接:https://cn.vjudge.net/problem/CodeForces-12D
题目大意:给你一个人的三个信息,如果存在一个人比当前人的这三个信息都大,那么这个人就会退出,问你最终有多少人退出。
具体思路:首先按照x的大小排序,大的在前面,然后对y进行离散化,其次就该使用线段树了,将y表示成区间,每一次更新的是y当前的到最大节点,然后线段树中储存的是z值,这样的话,每一次查询,在保证x变大的同时,通过对当前y+1-》siz的区间的z值的最大值,就能判断了。
AC代码:
#include<iostream>
#include<stack>
#include<stdio.h>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
# define lson l,m,rt<<
# define rson m+,r,rt<<|
# define ll long long
const int maxn = 1e5+;
ll sto1[maxn],sto2[maxn];
ll sto3[maxn];
ll cal(ll t1,ll t2)
{
ll tmp=;
while(t2)
{
tmp+=(t2/t1);
t2/=t1;
}
return tmp;
}
int main()
{
ll n,m,tmp;
scanf("%lld %lld",&n,&m);
tmp=m;
int num=;
for(ll i=; i*i<=m; i++)
{
int res=;
if(tmp%i==)
{
sto1[++num]=i;
while(tmp%i==)
{
tmp/=i;
res++;
}
sto2[num]=res;
}
}
if(tmp!=)sto1[++num]=tmp,sto2[num]=;
for(int i=; i<=num; i++)
{
sto3[i]=cal(sto1[i],n);
// cout<<sto1[i]<<" "<<sto2[i]<<" "<<sto3[i]<<endl;
}
ll minn=9e18+;
for(int i=; i<=num; i++)
{
minn=min(minn,sto3[i]/sto2[i]);
}
printf("%lld\n",minn);
return ;
}
Ball CodeForces - 12D (线段树)的更多相关文章
- 【arc073e】Ball Coloring(线段树,贪心)
[arc073e]Ball Coloring(线段树,贪心) 题面 AtCoder 洛谷 题解 大型翻车现场,菊队完美压中男神的模拟题 首先钦定全局最小值为红色,剩下的袋子按照其中较大值排序. 枚举前 ...
- Bash and a Tough Math Puzzle CodeForces 914D 线段树+gcd数论
Bash and a Tough Math Puzzle CodeForces 914D 线段树+gcd数论 题意 给你一段数,然后小明去猜某一区间内的gcd,这里不一定是准确值,如果在这个区间内改变 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 831E) - 线段树 - 树状数组
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...
- Ball CodeForces - 12D
传送门 N ladies attend the ball in the King's palace. Every lady can be described with three values: be ...
- Codeforces 938G 线段树分治 线性基 可撤销并查集
Codeforces 938G Shortest Path Queries 一张连通图,三种操作 1.给x和y之间加上边权为d的边,保证不会产生重边 2.删除x和y之间的边,保证此边之前存在 3.询问 ...
- codeforces 1136E 线段树
codeforces 1136E: 题意:给你一个长度为n的序列a和长度为n-1的序列k,序列a在任何时候都满足如下性质,a[i+1]>=ai+ki,如果更新后a[i+1]<ai+ki了, ...
- Z - New Year Tree CodeForces - 620E 线段树 区间种类 bitset
Z - New Year Tree CodeForces - 620E 这个题目还没有写,先想想思路,我觉得这个题目应该可以用bitset, 首先这个肯定是用dfs序把这个树转化成线段树,也就是二叉树 ...
- D - The Bakery CodeForces - 834D 线段树优化dp···
D - The Bakery CodeForces - 834D 这个题目好难啊,我理解了好久,都没有怎么理解好, 这种线段树优化dp,感觉还是很难的. 直接说思路吧,说不清楚就看代码吧. 这个题目转 ...
- B - Legacy CodeForces - 787D 线段树优化建图+dij最短路 基本套路
B - Legacy CodeForces - 787D 这个题目开始看过去还是很简单的,就是一个最短路,但是这个最短路的建图没有那么简单,因为直接的普通建图边太多了,肯定会超时的,所以要用线段树来优 ...
随机推荐
- The Unique MST POJ - 1679 (次小生成树)
Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spann ...
- poj2632 【模拟】
In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure ...
- MT【232】展开式中的系数
$(1+x+x^2+\cdots+x^{100})^3$展开式中$x^{150}$前的系数为_____ 解答:$(1+x+x^2+\cdots+x^{100})^3=(1-x^{101})^3\sum ...
- 自学Aruba3.2-Aruba配置架构-Virtual AP配置要点
点击返回:自学Aruba之路 自学Aruba3.2-Aruba配置架构-Virtual AP配置要点 1. AP.AP-Group和Virtual-AP的关系 解析列举: AP1.AP3, ...
- BZOJ 3526: [Poi2014]Card
3526: [Poi2014]Card Time Limit: 25 Sec Memory Limit: 64 MBSubmit: 267 Solved: 191[Submit][Status][ ...
- SharePoint 2013 event id 8321 错误
SharePoint 2013里会报8321的错误: A certificate validation operation took 15011.1412 milliseconds and has e ...
- 洛谷 P1984 [SDOI2008]烧水问题 解题报告
P1984 [SDOI2008]烧水问题 题目描述 把总质量为1kg的水分装在n个杯子里,每杯水的质量均为(1/n)kg,初始温度均为0℃.现需要把每一杯水都烧开.我们可以对任意一杯水进行加热.把一杯 ...
- c++ 静态变量报错 undefined reference to static members
c++中静态变量不但要在头文件中declare,还要在实现的cpp中declare.当然也可以赋个初始值. class foo { int _i; public: foo(int i) : _i(i) ...
- (转)使用 Spring缓存抽象 支持 EhCache 和 Redis 混合部署
背景:最近项目组在开发本地缓存,其中用到了redis和ehcache,但是在使用注解过程中发现两者会出现冲突,这里给出解决两者冲突的具体方案. spring-ehcache.xml配置: <?x ...
- 斯坦福大学公开课机器学习:梯度下降运算的特征缩放(gradient descent in practice 1:feature scaling)
以房屋价格为例,假设有两个特征向量:X1:房子大小(1-2000 feets), X2:卧室数量(1-5) 关于这两个特征向量的代价函数如下图所示: 从上图可以看出,代价函数是一个又瘦又高的椭圆形轮廓 ...