bzoj 2793 [Poi2012]Vouchers 调和级数求和
2016-11-14 20:25
387 查看
就是维护一下每个值现在取到几。复杂度调和级数求和nlogn
#include <bits/stdc++.h> using namespace std; #define N 1100000 #define ll long long int n,m,mx,top; int a ,pos ; ll now,bel ,st ; int main() { //freopen("tt.in","r",stdin); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]),mx=max(mx,a[i]); scanf("%d",&m); for(int x;m--;) { scanf("%d",&x); for(int i=pos[x]+x,cnt=0;cnt<x&&i<=mx;i+=x) if(!bel[pos[x]=i]) { bel[i]=now+cnt+1; cnt++; } now+=x; } for(int i=1;i<=n;i++) if(bel[a[i]]) st[++top]=bel[a[i]]; printf("%d\n",top); sort(st+1,st+1+top); for(int i=1;i<=top;i++) printf("%lld\n",st[i]); return 0; }
相关文章推荐
- 【BZOJ2793】[Poi2012]Vouchers 调和级数
- bzoj 2793 [Poi2012] Vouchers 调和级数
- BZOJ 2793: [Poi2012]Vouchers(调和级数)
- BZOJ2793 [Poi2012]Vouchers 调和级数
- 【bzoj2793】[Poi2012]Vouchers 暴力
- BZOJ2793: [Poi2012]Vouchers
- bzoj 2793: [Poi2012]Vouchers 乱搞
- BZOJ2793: [Poi2012]Vouchers
- bzoj2793: [Poi2012]Vouchers
- [BZOJ2793][Poi2012]Vouchers
- BZOJ2793: [Poi2012]Vouchers
- 【BZOJ2793】【数学】[Poi2012]Vouchers
- 2793: [Poi2012]Vouchers
- bzoj 2790 [Poi2012] Distance 转化+调和级数
- 【BZOJ】【P2793】【Poi2012】【Vouchers】【题解】【乱搞】
- 2793 [Poi2012]Vouchers
- BZOJ2792 : [Poi2012]Well
- [BZOJ2795] [Poi2012] [字符串hash] A Horrible Poem
- [JZOJ5442]【NOIP2017提高A组冲刺11.1】荒诞([BZOJ3060]【POI2012】Tour de Byteotia)
- BZOJ2788: [Poi2012]Festival