BZOJ2793: [Poi2012]Vouchers
来源:互联网 发布:淘宝后台装修教程视频 编辑:程序博客网 时间:2024/06/08 02:43
题目大意:定义n个数为幸运数字,一共有n批人,设第i批人有x个,则它们会依次取走余下的x的倍数中最小的x个,问哪些人去走了幸运数字
因为幸运数字大小都是1000000以内的,所以我们只需要维护1000000以内的数取没取走以及以他们为约数都取到哪了,当新的取数操作开始时就暴力找,根据调和级数,所有数加起来一共只能NlogN步,所以时间复杂度是能保证的
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define N 1000010using namespace std;int now[N];bool f[N];int tot;long long cnt,ans[N];bool used[N];int main(){int n,m;int j,x,y;long long i;scanf("%d",&n);for(i=1;i<=n;i++) {scanf("%d",&x);f[x]=true;}scanf("%d",&m);while(m--){scanf("%d",&x);for(i=1;i<=x;i++){now[x]+=x;while(now[x]<=1000000&&used[now[x]]) now[x]+=x;if(now[x]>1000000) break;used[now[x]]=true;if(f[now[x]]) tot++,ans[tot]=cnt+i;}cnt+=x;}printf("%d\n",tot);for(i=1;i<=tot;i++)printf("%lld\n",ans[i]);}
0 0
- BZOJ2793 [Poi2012]Vouchers 调和级数
- BZOJ2793: [Poi2012]Vouchers
- BZOJ2793 [Poi2012]Vouchers
- BZOJ2793/POI2012 Vouchers
- BZOJ2793: [Poi2012]Vouchers
- bzoj2793.Vouchers(调和级数)
- 2793: [Poi2012]Vouchers
- bzoj 2793: [Poi2012]Vouchers 乱搞
- 【BZOJ】【P2793】【Poi2012】【Vouchers】【题解】【乱搞】
- bzoj 2793 [Poi2012]Vouchers 调和级数求和
- [POI 2012]Vouchers
- POI2012题解
- [Poi2012]Festival
- BZOJ 2789: [Poi2012]Letters
- [BZOJ 2790]POI2012 Distance
- [BZOJ 2789]POI2012 Letters
- [BZOJ 2791]POI2012 Rendezvous
- [BZOJ 2803]Poi2012 Prefixuffix
- 坐标象限法判断矩形之间最短的距离
- Introduction to Hierarchical State Machines (HSMs)
- AndroidStudio引入so文件
- 【Spring4揭秘 BeanFactory】BeanFactory中Bean的实例化过程
- OpenCV学习之视频读取与帧的提取、显示及保存
- BZOJ2793: [Poi2012]Vouchers
- Android样式的开发:shape篇
- java 汉字排序
- NSDictionary的一些使用
- html——制作音乐盒
- Android消息机制初步分析
- 知识点
- How to set up bee git repo and using lkp
- 使用DX 编译 Android应用