codeforces 691F Couple Cover 暴力
分析:开一个300w的数组,统计,然后nlogn统计每个值在在序对第一个出现有多少种情况
时间复杂度:O(nlogn) n在3e6数量级
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 3e6;
const LL mod = 1e9+;
LL n,m,sum[N+],c[N+];
int main(){
scanf("%I64d",&n);
int mx=;
for(int i=;i<=n;++i){
int x;scanf("%d",&x);++c[x];
mx=max(x,mx);
}
for(int i=;i<=mx;++i){
for(int j=;j<=mx;++j){
if(1ll*i*j>N)break;
if(i==j)sum[i*j]+=c[i]*(c[i]-);
else sum[i*j]+=c[i]*c[j];
}
}
for(int i=;i<=N;++i)sum[i]+=sum[i-];
scanf("%I64d",&m);
while(m--){
int p;
scanf("%d",&p);
printf("%I64d\n",n*(n-)-sum[p-]);
}
return ;
}
codeforces 691F Couple Cover 暴力的更多相关文章
- [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力
Couple Cover Time Limit: 3000MS Memory Limit: 524288KB 64bit IO Format: %I64d & %I64u Descri ...
- Codeforces 691F Couple Cover
可以暴力预处理出每一种小于3000000的乘积有几种.询问的时候可以用总的方案减去比p小的有几种o(1)输出. #pragma comment(linker, "/STACK:1024000 ...
- codeforces 691F 暴力
传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...
- codeforces 691F F. Couple Cover(组合计数)
题目链接: F. Couple Cover time limit per test 3 seconds memory limit per test 512 megabytes input standa ...
- codeforces 724B Batch Sort(暴力-列交换一次每行交换一次)
题目链接:http://codeforces.com/problemset/problem/724/B 题目大意: 给出N*M矩阵,对于该矩阵有两种操作: (保证,每行输入的数是 1-m 之间的数且不 ...
- codeforces 897A Scarborough Fair 暴力签到
codeforces 897A Scarborough Fair 题目链接: http://codeforces.com/problemset/problem/897/A 思路: 暴力大法好 代码: ...
- Educational Codeforces Round 14 - F (codeforces 691F)
题目链接:http://codeforces.com/problemset/problem/691/F 题目大意:给定n个数,再给m个询问,每个询问给一个p,求n个数中有多少对数的乘积≥p 数据范围: ...
- Codeforces A. Playlist(暴力剪枝)
题目描述: Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- [codeforces 200 A Cinema]暴力,优化
题意大致是这样的:有一个有n行.每行m个格子的矩形,每次往指定格子里填石子,如果指定格子里已经填过了,则找到与其曼哈顿距离最小的格子,然后填进去,有多个的时候依次按x.y从小到大排序然后取最小的.输出 ...
随机推荐
- HTTP 408请求超时错误解决办法
错误描述 对于大多数网站而言,我们所看到的错误消息已经是开发者定制过的页面,比如我们最常见的自定义404错误页面,一般而言,我们看到的408错误应该是类似这样的提示:“408:Request Time ...
- hdu 1002 A+B
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1002 复习一下大数 模板: #include <stdio.h> #include <s ...
- cojs 西瓜 解题报告
首先我们要知道pick公式 设二维平面内任意多边形面积为S 设多边形内部整点数为a 设多边形边界的整点数为b 则满足S=a+b/2-1 变形得a=S-b/2+1 由期望的线性性质我们把问题转化为 1. ...
- cv 论文(CNN相关)
最近发现很多以前看的论文都忘了,所以想写点东西来整理下之前的paper,paper主要是cv(computer vision)方向的. 第一篇:Gradient-based learning appl ...
- 10 harsh truths that will help you grow
10 harsh truths that will help you grow帮你成长的10个残酷事实In the game of life, if it often seems like you’r ...
- ArcEngine查询、添加、删除要数的方法
原文地址:http://www.cnblogs.com/caodajieup/archive/2011/11/02/2232658.html 1.查找数据 1).利用FeaturCursor进行空间查 ...
- Android TextView多行文本滚动实现
Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局.只要在l ...
- JDBC学习总结(二)
1.JDBC的基本应用 1)创建数据库: create database test; use test; 2)创建表: create table student( id int(4) no ...
- linux协议栈部分资料
socket实现:http://blog.csdn.net/zhangskd(含有tcp/ip专栏) http://blog.chinaunix.net/uid-20528014-id-90573.h ...
- AutoResetEvent
private static readonly AutoResetEvent autoResetEvent = new AutoResetEvent(false); private static vo ...