题目传送门

 1 /*
 2     题意:问选出3个数成等比数列有多少种选法
 3     map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数。别人的代码很短,思维巧妙
 4 */
 5 /************************************************
 6  * Author        :Running_Time
 7  * Created Time  :2015-8-6 1:07:18
 8  * File Name     :C.cpp
 9  ************************************************/
10
11 #include <cstdio>
12 #include <algorithm>
13 #include <iostream>
14 #include <sstream>
15 #include <cstring>
16 #include <cmath>
17 #include <string>
18 #include <vector>
19 #include <queue>
20 #include <deque>
21 #include <stack>
22 #include <list>
23 #include <map>
24 #include <set>
25 #include <bitset>
26 #include <cstdlib>
27 #include <ctime>
28 using namespace std;
29
30 #define lson l, mid, rt << 1
31 #define rson mid + 1, r, rt << 1 | 1
32 typedef long long ll;
33 const int MAXN = 2e5 + 10;
34 const int INF = 0x3f3f3f3f;
35 const int MOD = 1e9 + 7;
36 map<ll, ll> c1, c2;
37
38 int main(void)    {     //Codeforces Round #Pi (Div. 2) C. Geometric Progression
39     ll ans = 0, x;  ll n, k;
40     scanf ("%I64d%I64d", &n, &k);
41     for (int i=1; i<=n; ++i)    {
42         scanf ("%I64d", &x);
43         if (x % (k * k) == 0)   ans += c1[x/k];     //x可选作第三个数
44         if (x % k == 0) c1[x] += c2[x/k];           //x第三个数或第二个数
45         c2[x]++;
46     }
47
48     printf ("%I64d\n", ans);
49
50     return 0;
51 }

转载于:https://www.cnblogs.com/Running-Time/p/4709186.html

map Codeforces Round #Pi (Div. 2) C. Geometric Progression相关推荐

  1. Codeforces Round #Pi (Div. 2)(A,B,C,D)

    A题: 题目地址: Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> # ...

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

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

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

    B. Berland National Library Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  4. Codeforces Round #224 (Div. 2): C. Arithmetic Progression(模拟)

    题意: 给你n个数字,你需要再添加一个数字,使得最后所有数字排序之后任意相邻两个数之差全部相等,问可以添加多少种不同的数字 思路: 一看就是水题但是情况不少,没了 例如所有数字全部相等,只有两个数字, ...

  5. Codeforces Round #315 (Div. 2)

    题目传送:Codeforces Round #315 (Div. 2) A. Music 题意较难懂.只是仅仅要推公式就好了 注意到S+(q - 1) * t = q * t; 仅仅须要t等于S就可以 ...

  6. [CF]Codeforces Round #529 (Div. 3)

    [CF]Codeforces Round #529 (Div. 3) C. Powers Of Two Description A positive integer xx is called a po ...

  7. CodeCraft-21 and Codeforces Round #711 (Div. 2) 题解

    先上链接CodeCraft-21 and Codeforces Round #711 (Div. 2) A: 从n开始往后找,不出几十个 一定能找到的,所以暴力就好了 void sovle(){cin ...

  8. Codeforces Round #510 (Div. 2)

    Codeforces Round #510 (Div. 2) https://codeforces.com/contest/1042 A 二分 1 #include<iostream> 2 ...

  9. Codeforces Round #706 (Div. 2)B. Max and Mex

    Codeforces Round #706 (Div. 2)B. Max and Mex 题目 题目大意 刚开始给你n个不同的数,k次询问每次求在该序列中已存在的最大的数和不存在的最小的数(大于等于零 ...

最新文章

  1. 那些不回微信的人,都在想什么?
  2. Java 基础 - 如何重写equals()
  3. 【Android 逆向】Android 进程注入工具开发 ( Visual Studio 开发 Android NDK 应用 | 使用 Makefile 构建 Android 平台 NDK 应用 )
  4. 通过实例理解word2vec之Skip-gram
  5. Android判断网络状态
  6. flask v0.1 执行流程 Flask(__name__)
  7. java入门第六天课程_Java基础学习第六天 小游戏
  8. Windows Server 2012 R2 WSUS-7:查看状态报告
  9. HTML5浏览器测试网站汇总
  10. 微信聊天内容制作生成器微信小程序源码_支持多种制作生成
  11. Skywalking vs Pinpoint
  12. CICD概念 k8s DevOps
  13. C# ListView 在指定行后面插入新行,并对行号重新排序。
  14. FlinkX配置文件解析
  15. oracle48108,​记一次oracle连接数暴涨hang分析经验
  16. springboot整合sse
  17. 随鼠标滚轮缩小和放大图片
  18. 做一名有幸福感的计算机教师,做一名具有幸福感的教师
  19. html5 canvas纯js开发战棋类rpg游戏
  20. 使用python如何测试webservice接口

热门文章

  1. HIVE大数据出现倾斜怎么办
  2. 带你玩转JavaWeb开发之四 -如何用JS做登录注册页面校验
  3. 2016 Bird Cup ICPC7th@ahstu--“波导杯”安徽科技学院第七届程序设计大赛
  4. 数据结构上机实践第五周项目1- 建立顺序栈算法库
  5. 一元流量参数为null_精益SQL —— “NULL”真烦人
  6. 学计算机的会excel,超级容易学电脑--Excel电子表格
  7. mac os x 10.11 php7,mac osx 10.11.2安装PHP7提示“configure: error: libcrypto not found!”
  8. 初中信息技术认识计算机,初中信息技术 认识计算机
  9. python跟excel_Python与Excel 不得不说的事情
  10. c语言三元运算符_了解C / C ++中的三元运算符