可以暴力预处理出每一种小于3000000的乘积有几种。询问的时候可以用总的方案减去比p小的有几种o(1)输出。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi = acos(-1.0), eps = 1e-;
void File()
{
freopen("D:\\in.txt", "r", stdin);
freopen("D:\\out.txt", "w", stdout);
}
inline int read()
{
char c = getchar(); while (!isdigit(c)) c = getchar();
int x = ;
while (isdigit(c)) { x = x * + c - ''; c = getchar(); }
return x;
} const int maxn=+;
int n,q;
LL a[maxn],c[*maxn],f[*maxn]; void init()
{
for(LL i=;i<=;i++)
{
if(c[i]==) continue;
for(LL j=;j<=i;j++)
{
if(c[j]==) continue;
if(i*j>) break;
if(i==j) f[i*j]=f[i*j]+c[i]*(c[j]-);
else f[i*j]=f[i*j]+*c[i]*c[j];
}
}
for(int i=;i<=;i++) f[i]=f[i]+f[i-];
} int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) { scanf("%lld",&a[i]); c[a[i]]++; }
init();
scanf("%d",&q);
for(int i=;i<=q;i++)
{
LL p; scanf("%lld",&p);
printf("%lld\n",(LL)n*(n-)-f[p-]);
}
return ;
}

Codeforces 691F Couple Cover的更多相关文章

  1. [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力

    Couple Cover Time Limit: 3000MS   Memory Limit: 524288KB   64bit IO Format: %I64d & %I64u Descri ...

  2. codeforces 691F Couple Cover 暴力

    分析:开一个300w的数组,统计,然后nlogn统计每个值在在序对第一个出现有多少种情况 时间复杂度:O(nlogn) n在3e6数量级 #include<cstdio> #include ...

  3. codeforces 691F F. Couple Cover(组合计数)

    题目链接: F. Couple Cover time limit per test 3 seconds memory limit per test 512 megabytes input standa ...

  4. codeforces 691F 暴力

    传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...

  5. Educational Codeforces Round 14 - F (codeforces 691F)

    题目链接:http://codeforces.com/problemset/problem/691/F 题目大意:给定n个数,再给m个询问,每个询问给一个p,求n个数中有多少对数的乘积≥p 数据范围: ...

  6. codeforces 691F(组合数计算)

    Couple Cover, a wildly popular luck-based game, is about to begin! Two players must work together to ...

  7. B. Cover Points Codeforces Round #511 (Div. 2)【数学】

    题目: There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn). You need t ...

  8. CodeForces - 1047B Cover Points

    B. Cover Points time limit per test1 second memory limit per test256 megabytes inputstandard input o ...

  9. Codeforces 1175E Minimal Segment Cover

    题意: 有\(n\)条线段,区间为\([l_i, r_i]\),每次询问\([x_i, y_i]\),问要被覆盖最少要用多少条线段. 思路: \(f[i][j]\)表示以\(i\)为左端点,用了\(2 ...

随机推荐

  1. python入门:UTF-8转换成GBK编码

    #!/usr/bin/env python # -*- coding:utf-8 -*- #UTF-8转换成GBK编码 #temp(临时雇员,译音:泰坡) #decode(编码,译音:迪口德) #en ...

  2. 什么是python中的元类

    所属网站分类: python高级 > 面向对象 作者:goodbody 原文链接: http://www.pythonheidong.com/blog/article/11/ 来源:python ...

  3. Python如何查看变量在内存中的地址

    在python中可以用id()函数获取对象的内存地址. 用法: object = 1 + 2 object -- 对象

  4. gpg: signing failed: secret key not available

    1 使用png签名tag时报错“ jb@39:~/11$ git tag -s gpg -m "gpg"gpg: directory `/home/jb/.gnupg' creat ...

  5. 常用C/C++预处理指令详解

    预处理是在编译之前的处理,而编译工作的任务之一就是语法检查,预处理不做语法检查.预处理命令以符号“#”开头. 常用的预处理指令包括: 宏定义:#define 文件包含:#include 条件编译:#i ...

  6. javascript常见数据集

    目录 数组 对象 一.数组 创建方法 1 2 3 var arrayObj = new Array(); //创建一个数组             var arrayObj = new Array([ ...

  7. 前端PS切图技巧

    先选择“编辑”-“首选项” 打开,找到“参考线”    设置一下每格网格 100像素 5个细块 确定后 ctrl+‘ 出现网格.(通过网格对齐切图比用参考线切图更好). 如果使用PS cc的软件的话, ...

  8. 微信小程序开发 -- 点击右上角实现转发功能

    // 在page的js文件中加入以下代码/** * 用户点击右上角分享 */ onShareAppMessage: function () { }

  9. Java判断浏览器是微信还是支付宝

    private static final String WX_AGENT = "micromessenger"; private static final String ALI_A ...

  10. javascript学习笔记 - 引用类型 Date

    三 Date new Date() 在不传递参数的情况下,新创建的对象自动获得当前日期和时间.参数接收毫秒的timestamp Date.parse() 接收表示日期的字符串,返回相应的日期毫秒数ti ...