BZOJ2793 [Poi2012]Vouchers
来源:互联网 发布:淘宝拖鞋底 编辑:程序博客网 时间:2024/06/05 16:00
记录每个值的倍数都取到哪了,如果大于最大的幸运数就肯定取不到了,根据调和级数复杂度n log n
#include<iostream>#include<cstdlib>#include<cstdio>#include<cstring>#include<cmath>#include<ctime>#include<algorithm>#include<iomanip>#include<vector>#include<stack>#include<queue>#include<map>#include<set>#include<bitset>using namespace std;#define MAXN 1000010#define MAXM 1010#define ll long long#define INF 1000000000#define MOD 1000000007#define eps 1e-8int m,n;bool lky[MAXN];int now[MAXN];bool vis[MAXN];int mx;ll tot;int ANS;ll ans[MAXN];int main(){int i,x;scanf("%d",&m);for(i=1;i<=m;i++){scanf("%d",&x);lky[x]=1;mx=max(mx,x);}scanf("%d",&n);for(i=1;i<MAXN;i++){now[i]=i;}while(n--){scanf("%d",&x);for(i=1;i<=x;i++){tot++;while(now[x]<=mx&&vis[now[x]]){now[x]+=x;}if(now[x]>mx){i++;break;}if(lky[now[x]]){ans[++ANS]=tot;}vis[now[x]]=1;}tot+=x-i+1; }printf("%d\n",ANS);for(i=1;i<=ANS;i++){printf("%lld\n",ans[i]);}return 0;}/**/
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
- ionic-myAppDemo项目分析
- Ubuntu Server 14.04 x64安装StatsD
- List逆转
- android-R.array
- Android蓝牙低功耗开发
- BZOJ2793 [Poi2012]Vouchers
- intellij idea让资源文件自动更新
- 做菜感悟
- 程序设计的基本概念
- 使用Sublime Text3+Ctags+Cscope替代Source Insight
- Spring 一个接口多个实现注入
- 旋转:矩阵,四元数和欧拉角向量(1)
- Ubuntu Server 14.04 x64安装Grafana
- Qr-Code encode and decode with python+qrcode+zbar