[ 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 ...
随机推荐
- 信息设计工具IDT创建从SAP Business Object到SAP HANA的连接
1. 打开Information Design Tool, 并添加BO Server的连接 2. 在Connection上右击, 选择Insert Relational Connection 3. 输 ...
- 加班计时App
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- python项目练习地址
作者:Wayne Shi链接:http://www.zhihu.com/question/29372574/answer/88744491来源:知乎著作权归作者所有,转载请联系作者获得授权. 目前是3 ...
- ios监听ScrollView/TableView滚动的正确姿势
主要介绍 监测tableView垂直滚动的舒畅姿势 监测scrollView/collectionView横向滚动的正确姿势 1.监测tableView垂直滚动的舒畅姿势 通常我们用KVO或者在scr ...
- IOS Android支持中文与本地文件的读取写入
转自http://www.xuanyusong.com/archives/1069 和http://www.benmutou.com/archives/2094 前几天有个朋友问我为什么在IOS平台中 ...
- java中equals方法和contentEquals方法区别
java中,String类里提供了两种字符串的比较方式(算上“==”应该是三种) String line1 = new String("0123456789"); String l ...
- JQuery笔记(二)jq常用方法animate()
在jq中,比较方便的是相对于js,jq封装了很多方法,很方便使用,下面我举几个常用的方法 animate()方法 <!DOCTYPE html> <html lang="e ...
- matlab,xls转换为mat文件
b=xlsread('iris_data.xls');save iris_data.mat b
- Base algorithm
今天介绍几种常见的算法,在面试中或许能派上用场 1.字符串倒转 //Reverse a string public static string Reverse(string ori) { string ...
- fbset视频参数说明
在机器上输入:fbset mode "1280x720-55" # D: 67.504 MHz, H: 40.961 kHz, V: 54.907 Hz geometry 128 ...