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 ...
随机推荐
- 【ZJOI2017 Round1练习】D8T2 sequence(DP)
题意: 思路: #include <algorithm> #include <iostream> #include <cstring> #include <c ...
- [bzoj3160]万径人踪灭_FFT_Manacher
万径人踪灭 bzoj-3160 题目大意:给定一个ab串.求所有的子序列满足:位置和字符都关于某条对称轴对称而且不连续. 注释:$1\le n\le 10^5$. 想法: 看了大爷的题解,OrzOrz ...
- springmvc @ResponseBody 乱码
在spring配置文件中加入如下代码 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMet ...
- ubuntu12.04+cuda6.0+opencv2.4.9
更新了cuda之后,opencv的gpu模块又要重新编译了,这个地方有一个疑问,我对cuda6.0装了两次,第一次装好之后,没有配一个bumblebee,重装了cuda6.0之后,发现原来编译的ope ...
- 百度语音识别API初探
近期想做个东西把大段对话转成文字.用语音输入法太慢,所以想到看有没有现成的API,网上一搜,基本就是百度和讯飞. 这里先看百度的 笔者使用的是Java版本号的 下载地址:http://bos.nj.b ...
- ubuntu 中 iptables 和 ufw 的关系
我突然发现,自己平常使用的 iptables 和 ufw 到底是啥关系?平常其实iptables和ufw在配置防火墙,开启端口是,还是偶尔会使用到的. 没去思考过这两者是啥关系,哎...,这就不够好了 ...
- 015 WAN
Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0/ ...
- reactjs 视频教程
近期玩了一下react,感觉挺不错的,搜了一下没有看到什么视频教程,于是自己便录制了几个入门视频.希望能够帮到大家.已经上传土豆了,能够点击以下的链接查看. http://www.tudou.com/ ...
- yarn-cli 显示文件目录
显示yarn bin文件夹的位置. yarn bin yarn bin将打印yarn将为您的软件包安装可执行文件的文件夹.一个可执行文件的例子可能是你已经为你的包定义的脚本,可以通过执行yarn ru ...
- URAL 题目1553. Caves and Tunnels(Link Cut Tree 改动点权,求两点之间最大)
1553. Caves and Tunnels Time limit: 3.0 second Memory limit: 64 MB After landing on Mars surface, sc ...