题意 : 给你一个序列,和 K ,选3 个数,下标严格递增, 满足 为递增的等比数列, 等比为K

思路 : 先统计所有数的个数,枚举等比数列的中间数 A, 计算 A 之后的 A*K的个数, A之前的 A /K 的个数,相乘

(打比赛脑残,还想到啪啪什么的,爱残了)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
//#include<bits/std c++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1e7 + 7;
const LL maxn = 1e5 + 131;
map<LL,LL> Num1;
map<LL,LL> Num2;
LL Line[maxn<<1];
LL N,K;
int main()
{
while(cin >> N >> K)
{
LL Sum = 0;
Num1.clear(); Num2.clear();
for(int i = 1; i <= N; ++i)
cin >> Line[i], Num1[Line[i]] ++;
for(int i = N; i >= 1; --i)
{
Num2[Line[i]]++;
if(i == 1 || i == N )continue;
if(Num2.count(Line[i] * K) && !(Line[i] % K))
{
LL L,R;
if(Line[i] == Line[i]* K) R = Num2[Line[i]*K] - 1;
else R = Num2[Line[i]*K];
L = Num1[Line[i] / K] - Num2[Line[i] / K];
Sum += (L * R);
}
}
cout << Sum << endl;
}
}

Codeforces Round #Pi (Div. 2) C的更多相关文章

  1. map Codeforces Round #Pi (Div. 2) C. Geometric Progression

    题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /***************** ...

  2. 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library

    题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...

  3. Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set乱搞

    D. One-Dimensional Battle ShipsTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  4. Codeforces Round #Pi (Div. 2) C. Geometric Progression map

    C. Geometric Progression Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  5. Codeforces Round #Pi (Div. 2) B. Berland National Library set

    B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  6. Codeforces Round #Pi (Div. 2) A. Lineland Mail 水

    A. Lineland MailTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/proble ...

  7. Codeforces Round #Pi (Div. 2) E. President and Roads 最短路+桥

    题目链接: http://codeforces.com/contest/567/problem/E 题意: 给你一个带重边的图,求三类边: 在最短路构成的DAG图中,哪些边是必须经过的: 其他的(包括 ...

  8. Codeforces Round #Pi (Div. 2) E. President and Roads tarjan+最短路

    E. President and RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567 ...

  9. Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set区间分解

    D. One-Dimensional Battle ShipsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  10. Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟

    B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

随机推荐

  1. Spring中的ApplicationContextAware使用

          加载Spring配置文件时,如果Spring配置文件中所定义的Bean类实现了ApplicationContextAware 接口,那么在加载Spring配置文件时,会自动调用Applic ...

  2. Hash碰撞 & 拒绝服务漏洞

    前段时间在网上看到的: http://www.baidu.com/s?wd=Hash%E7%A2%B0%E6%92%9E+++%E6%8B%92%E7%BB%9D%E6%9C%8D%E5%8A%A1% ...

  3. 解决TypeError: __init__() missing 1 required positional argument: 'on_delete'

    试用Djiango的时候发现执行mange.py makemigrations 和 migrate是会报错,少位置参数on_delete,查了一下是因为指定外键的方式不对,改一下就OK了. 代码如下: ...

  4. MATLAB:图像选取局部区域滤波(roicolor、roipoly、roifill、fspecial、roifilt2函数)

    对于某些特殊的图像处理,我们不希望将整张图都进行图像处理.这个时候就用到了roicolor.roipoly.roifill.fspecial.roifilt2函数.代码实现过程如下: close al ...

  5. java代码示例(2)

    /** * 目的:求各位之和 * @author chenyanlong * 时间:2017/10/14 */ package com.hp.test02; import java.util.Scan ...

  6. SQL记录-资源正忙online或nowait

    1.多个tomcat 修改3个端口 2.oracle-00054:资源正忙 被锁住了 建立索引加online参数 1:创建索引时会产生的锁 2:dml 语句会产生的锁 3:索引创建时加上关键字 onl ...

  7. zabbix微信预警出现的问题

    系统环境:centos7.3 zabbix_server: 3.0.3 3.0.6 问题描述 zabbix预警突然不能发送微信,需要修复 排查步骤 1. 检查微信企业平台应用的key是否过期,结果没过 ...

  8. Linux 设置最大链接

    最大连接数 ulimit -SHn # 最大文件句柄数,最大打开文件数(等同最大连接数) ulimit -a # 查看 /etc/security/limits.conf # 进程最大打开文件数 # ...

  9. luogu P4162 [SCOI2009]最长距离

    传送门 可以枚举两个点然后计算答案,至于是否合法,就要看可不可以通过移不超过\(t\)个箱子使得两点连通,也可以看做找一条路径使得路径上的1个数不超过\(t\) 所以可以考虑最短路,相邻的点两两连边, ...

  10. 【Gradle】Gradle环境配置

    Windows环境 下载 作者下载的是gradle-4.1-all.zip,下载地址:http://services.gradle.org/distributions 环境配置 GRADLE_HOME ...