题意 : 给你一个序列,和 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. dedecms获取顶级栏目名称、二级栏目名称实现方法 转

    织梦DEDECMS文章.栏目页获取当前页面顶级栏目名称的方法 在用织梦做一些项目时,时常会碰到需要在当前页面调用顶级栏目名称的时候,织梦默认{dede:field name='typename' /} ...

  2. 关闭应用程序(主程序)(WPF)

    很多人认为关闭应用程序应该很简单,例如WindowsForm里一个Application.Exit();方法就可以解决问题,但在WPF里面可别滥用,因为WPF里Application类没有该方法,倒是 ...

  3. 批处理 ------ @、ECHO OFF、ECHO ON 的使用

    1.在批处理文件中,如果命令前加@,表示这条命令不打印出来,只把结果打印出来,即@是关闭命令本身的回显 2.::在批处理中表示注释某一行 3.ECHO ON表示接下来的命令中(不包括本命令),执行命令 ...

  4. 化工pdf下载

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

  5. python-web开发环境搭建

    一.安装distribute或setuptools,我用的distribute 下载链接:https://pypi.python.org/pypi/distribute [root@yeebian o ...

  6. ATS 自定义日志格式

    字段解释 %<chi> 客户端IP %<caun> The username of the authenticated client. A hyphen (-) means t ...

  7. html5 实时监听输入框值变化的完美方案:oninput & onpropertychange

    结合 HTML5 标准事件 oninput 和 IE 专属事件 onpropertychange 事件来监听输入框值变化. H5手机端: <input type="text" ...

  8. odp.net连接方式,部署问题总结

      一. 摘要 在C#开发的过程中,经常需要操作Oracle数据库,而实际在部署程序的时候,经常要根据系统环境(32.64bit).不安装Oracle客户端等等需求,而Odp.net 也没有完美兼容的 ...

  9. Elaticsearch 集群

    elasticsearch开源的搜索引擎:  ElasticSearch 个基于Lucene的搜索服务器:可以使用多节点的备份:集群设置: (类似是个数据库型.有索引有什么的).(lucene apa ...

  10. <转载>iTerm2使用技巧

    原文链接:http://www.cnblogs.com/756623607-zhang/p/7071281.html   1.设置窗口 定位到 [Preferences - Profiles - Wi ...