map Codeforces Round #Pi (Div. 2) C. Geometric Progression
/*
题意:问选出3个数成等比数列有多少种选法
map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数。别人的代码很短,思维巧妙
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-6 1:07:18
* File Name :C.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
map<ll, ll> c1, c2; int main(void) { //Codeforces Round #Pi (Div. 2) C. Geometric Progression
ll ans = , x; ll n, k;
scanf ("%I64d%I64d", &n, &k);
for (int i=; i<=n; ++i) {
scanf ("%I64d", &x);
if (x % (k * k) == ) ans += c1[x/k]; //x可选作第三个数
if (x % k == ) c1[x] += c2[x/k]; //x第三个数或第二个数
c2[x]++;
} printf ("%I64d\n", ans); return ;
}
map Codeforces Round #Pi (Div. 2) C. Geometric Progression的更多相关文章
- 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 ...
- Codeforces Round #Pi (Div. 2) C. Geometric Progression
C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...
- Codeforces Round #Pi (Div. 2)(A,B,C,D)
A题: 题目地址:Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> #i ...
- codeforces Round #Pi (div.2) 567ABCD
567A Lineland Mail题意:一些城市在一个x轴上,他们之间非常喜欢写信交流.送信的费用就是两个城市之间的距离,问每个城市写一封信给其它城市所花费的最小费用和最大的费用. 没什么好说的.直 ...
- Codeforces Round #Pi (Div. 2) ABCDEF已更新
A. Lineland Mail time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...
- 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 ...
- 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 ...
- Codeforces Round #Pi (Div. 2) A. Lineland Mail 水
A. Lineland MailTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/proble ...
随机推荐
- hiho一下 第五十周 (求欧拉路径)
http://hihocoder.com/contest/hiho50/problem/1 这题有重边,所以邻接矩阵用来统计节点u,v之间有多少条边相连,并且用另外一个数组统计每个节点的入度. 然后查 ...
- Codeforces 645A Amity Assessment【八数码】
题目链接: http://codeforces.com/problemset/problem/645/A 题意: 2*2的八数码问题 分析: 这题n为2,不需要搜索,直接判断字母排列顺序就好了. 注意 ...
- Restful 级别划分以及HATEOAS是什么?
Restful简介 Rest是一种软件架构风格.设计风格,而不是标准,只是提供了一组设计原则和约束条件.它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存 ...
- 【.Net 学习系列】-- FileSystemWatcher 监控文件夹新生成文件,并在确认文件没有被其他程序占用后将其移动到指定文件夹
监控文件夹测试程序: using System; using System.Collections.Generic; using System.IO; using System.Linq; using ...
- openstack setup demo Image service
Image service (glance)是openstack中管理vm image的service.本文包含以下内容: overview install overview glance包含以下部分 ...
- ubuntu12.04+cuda6.0+opencv2.4.9
更新了cuda之后,opencv的gpu模块又要重新编译了,这个地方有一个疑问,我对cuda6.0装了两次,第一次装好之后,没有配一个bumblebee,重装了cuda6.0之后,发现原来编译的ope ...
- Dubbo-admin无法显示Group分组信息
背景: 在首次使用Dubbo的时候.我们可能都会使用Dubbo-admin来监控服务的提供者和消费者,可是在自己的生产者成功执行的时候.在Dubbo-admin却看不到不论什么信息.假设在确保代码的正 ...
- linux man 1,2,3 命令
原文: http://blog.sina.com.cn/s/blog_969c52730101c0p7.html ------------------------------------------- ...
- HTTP请求方式之GET和POST比较
什么是HTTP协议 超文本传输协议(HyperText Transfer Protocol -- HTTP)是一个设计来使客户端和服务器顺利进行通讯的协议 HTTP在客户端和服务器之间以request ...
- Mac使用技巧之Finder的个人收藏
当使Finder的时候,左側会列出来个人收藏,能够非常方便的打开对应的文件夹.那么怎样把自己新建的文件夹也增加到个人收藏呢? 1.默认的个人收藏 2.新建名字为my_ios_demo文件夹,拖动这个文 ...