我们直接模拟就可以了= =

now[x]表示x的倍数已经取到x * i了,于是每次读入x,直接向上枚举x个没取过的数即可。

 /**************************************************************
Problem: 2793
User: rausen
Language: C++
Result: Accepted
Time:5296 ms
Memory:14476 kb
****************************************************************/ #include <cstdio>
#include <algorithm> using namespace std;
typedef long long ll;
const int N = ; int n, m, mx;
int now[N];
ll tot, ans[N], cnt;
bool f[N], vis[N]; inline int read() {
int x = , sgn = ;
char ch = getchar();
while (ch < '' || '' < ch) {
if (ch == '-') sgn = -;
ch = getchar();
}
while ('' <= ch && ch <= '') {
x = x * + ch - '';
ch = getchar();
}
return sgn * x;
} int main() {
int i, x, t, C;
for (m = read(), i = ; i <= m; ++i) {
x = read();
f[x] = , mx = max(mx, x);
} n = read();
while (n--) {
x = t = read();
for (i = now[x] + x, C = ; i <= mx; i += x) {
if (!vis[i]) {
++cnt, --t, vis[i] = ;
if (f[i]) ans[++tot] = cnt;
if (++C == x) break;
}
now[x] = i;
}
cnt += t;
}
printf("%lld\n", tot);
for (i = ; i <= tot; ++i)
printf("%lld\n", ans[i]);
}

(p.s. 没有的搞懂,一开始各种WA,把ans数组改成long long就AC了?蒟蒻跪求大神求教)

2793 [Poi2012]Vouchers的更多相关文章

  1. BZOJ 2793: [Poi2012]Vouchers(调和级数)

    Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 582  Solved: 250[Submit][Status][Discuss] Description ...

  2. [BZOJ2793][Poi2012]Vouchers

    2793: [Poi2012]Vouchers Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 316  Solved: 148[Submit][Stat ...

  3. 【BZOJ2793】[Poi2012]Vouchers 调和级数

    [BZOJ2793][Poi2012]Vouchers Description 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个.正整 ...

  4. 【BZOJ2793】【数学】[Poi2012]Vouchers

    Description 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个. 正整数中有m个数被标成了幸运数,问有哪些人取到了幸运数. ...

  5. BZOJ2793[Poi2012]Vouchers——枚举

    题目描述 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个.正整数中有m个数被标成了幸运数,问有哪些人取到了幸运数. 输入 第一行一个 ...

  6. 【bzoj2793】[Poi2012]Vouchers 暴力

    题目描述 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个.正整数中有m个数被标成了幸运数,问有哪些人取到了幸运数. 输入 第一行一个 ...

  7. [POI2012]Vouchers

    Description 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个. 正整数中有m个数被标成了幸运数,问有哪些人取到了幸运数. ...

  8. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  9. POI2012题解

    POI2012题解 这次的完整的\(17\)道题哟. [BZOJ2788][Poi2012]Festival 很显然可以差分约束建图.这里问的是变量最多有多少种不同的取值. 我们知道,在同一个强连通分 ...

随机推荐

  1. XDU 1001 又是苹果(状态压缩)

    #include<cstdio> #include<cstring> ; using namespace std; int r[maxn],c[maxn]; char pic[ ...

  2. 国内Hadoop相关的开源项目

    1.BC-Hadoop:中国移动Hadoop工具链打包 https://github.com/cmri/bc-hadoop2.0 孵化阶段,将成为一个通用的开源Hadoop平台 2.BC-BSP:中国 ...

  3. Connecting to a Remote Serial Port over TCP/IP

    https://www.acmesystems.it/socat This article illustrates how to realize a lan to serial gateway Rem ...

  4. 2017 Multi-University Training Contest - Team 1 03Colorful Tree

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6035 题面: Colorful Tree Time Limit: 6000/3000 MS ( ...

  5. iOS 总结APP间跳转的常用以及非常用需求 APP跳转Safari APP跳转APP

    需求驱动技术,有了新的需求,旧技术无法实现时,就会有新的技术出现. 一般的APP跳转需求有以下几种: 1.  从自己的APP跳转到别人的APP. 2. 从自己的APP跳转系统APP. 3. 让别人的A ...

  6. [HNOI2019]校园旅行(构造+生成树+动规)

    题目 [HNOI2019]校园旅行 做法 最朴素的做法就是点对扩展\(O(m^2)\) 发现\(n\)比较小,我们是否能从\(n\)下手减少边数呢?是肯定的 单独看一个颜色的联通块,如果是二分图,我们 ...

  7. jQuery中this 和 $(this)

    var node = $('#id'); node.click(function(){ this.css('display','block'); //报错  this是一个html元素,不是jquer ...

  8. 软件测试技术作业3---PrintPrimes()

    一.代码部分: private static void printPrimes (int n) { int curPrime; // Value currently considered for pr ...

  9. CommonLang3 --StringUtils使用指南

    转载自(http://blog.csdn.net/xuxiaoxie/article/details/52095930)public static boolean isEmpty(CharSequen ...

  10. linux下挂载ISO像镜文件

    挂载命令(mount) 命令格式:mount [-t vfstype] [-o options] device dir其中:1.-t vfstype 指定文件系统的类型,通常不必指定.mount 会自 ...