[ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力
| Time Limit: 3000MS | Memory Limit: 524288KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
第i行输出对于当前pi值,方宝宝能赢的方案数。
Sample Input
Source
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=3e6+;
ll cnt[maxn];
ll sum[maxn];
ll n,m,a,max_=-;
int main(){
scanf("%I64d",&n);
for(int i=;i<n;i++){
scanf("%d",&m);
cnt[m]++;
if(m>max_) max_=m;
}
for(int i=;i<=max_;i++){
for(int j=;j<=max_;j++){
if(i*j>maxn) break;
sum[i*j]+=cnt[i]*cnt[j];
if(i==j) sum[i*j]-=cnt[j];
}
}
for(int i=;i<=maxn;i++)
sum[i]+=sum[i-];
scanf("%I64d",&m);
for(int i=;i<m;i++){
scanf("%d",&a);
printf("%I64d\n",n*(n-)-sum[a-]);
}
return ;
}
/* 5
4 2 6 1 3
4
1 3 5 8 2
5 6
2 */
[ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力的更多相关文章
- codeforces 691F Couple Cover 暴力
分析:开一个300w的数组,统计,然后nlogn统计每个值在在序对第一个出现有多少种情况 时间复杂度:O(nlogn) n在3e6数量级 #include<cstdio> #include ...
- Codeforces 691F Couple Cover
可以暴力预处理出每一种小于3000000的乘积有几种.询问的时候可以用总的方案减去比p小的有几种o(1)输出. #pragma comment(linker, "/STACK:1024000 ...
- codeforces 691F F. Couple Cover(组合计数)
题目链接: F. Couple Cover time limit per test 3 seconds memory limit per test 512 megabytes input standa ...
- codeforces 691F 暴力
传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...
- codeforces 691F(组合数计算)
Couple Cover, a wildly popular luck-based game, is about to begin! Two players must work together to ...
- codeforces 675B B. Restoring Painting(暴力枚举)
题目链接: B. Restoring Painting time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- CodeForces - 1013B And 与运算暴力
题目链接: https://vjudge.net/problem/1735275/origin 基本思路: 本题思路比较简单,首先,我们知道 a & x = b, b & x = b; ...
- codeforces 650D D. Image Preview (暴力+二分+dp)
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...
随机推荐
- 网站URL重写(Java UrlRewrite 的使用)
现在大部分的网站和商城都会使用到URL重写,接触到这个,也是因为正在做的电子商务商城.URL重写,是将原有的URL采用另一种规则来显示,使得用户方便访问同时也屏蔽一些信息. 在此说下它的好处,在开发过 ...
- class.forname()方法的学习(转)
Class.forName(xxx.xx.xx) 返回的是一个类 首先你要明白在java里面任何class都要装载在虚拟机上才能运行.这句话就是装载类用的(和new 不一样,要分清楚). 至于什么时候 ...
- %type的用法
//%type //如果声明的变量是直接映射到数据库的某一列上,那么就可以使用%type关键字将变量 //锚定到这个列上.这样做有什么好处呢? //比如: //declare v_ename scot ...
- JSON.toJSONString的jar包问题
toJSONString()方法的jar包不在json-lib中,简单点阿里巴巴给我们封装好的json包,也是开源的alibaba.fastjson.JSON,网上搜fastjson应该就有了.
- could not resolve property问题(ssh框架)
could not resolve property不能解析属性问题, 刚开始把hql语句中的"from User user where user.user_name = '"+u ...
- window下安装apache---使用wamp
01 wamp-server-wamp5-2-5-multi-win.exe 02 wamp报错时,需要的补丁(vcredist_x64.exe) 无法启动此程序,因为计算机中丢失MSVCR110.d ...
- 一个IT人士的个人经历,给迷失方向的朋友(转)
作者: 果子狸 来源: WP开发者社区 发布时间: 2013-11-08 10:43 阅读: 50078 次 推荐: 494 原文链接 [收藏] 这些日子我一直在写一个实时操作系统内核 ...
- ecshop 分页小记
ecshop 分页是ajax请求的,必须在主文件里有个 act = query 处理,分页会请求这个act <?php //获取列表 if($_REQUEST['act']=='list'){ ...
- 高一的我曾对自己说"要放慢脚步去生活"!?
看了高一的时候自己写的日记,瞬间被自己感动到了.以下是当时的几段感慨: 慢是一种放松.是生活的一种良好心态,喜欢这样放慢步伐地生活,那是一种享受! 但我们生活在一个快节奏的时代,我们总是被迫卷进那潮流 ...
- rebase
/BASE (Base Address) https://msdn.microsoft.com/en-us/library/f7f5138s.aspx Need for Rebasing a DLL( ...