Codeforces Round #Pi (Div. 2) C
题意 : 给你一个序列,和 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的更多相关文章
- map Codeforces Round #Pi (Div. 2) C. Geometric Progression
题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /***************** ...
- 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,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) 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) 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 ...
- Codeforces Round #Pi (Div. 2) E. President and Roads 最短路+桥
题目链接: http://codeforces.com/contest/567/problem/E 题意: 给你一个带重边的图,求三类边: 在最短路构成的DAG图中,哪些边是必须经过的: 其他的(包括 ...
- 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 ...
- 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 ...
- Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
随机推荐
- [bzoj4709][柠檬]
bzoj4709 思路 首先,最优秀的分法一定是每段两端都是这一段中最多的那个,否则可以把不是的那个踢出去单独成段肯定会更优秀.然后就成了将这个序列分段,保证每段两端元素相同的最大收益和. 用a[i] ...
- 辗转相除法求最大公约数(gcd)的斐波那契数列(fib)最坏时间复杂度的证明
下载地址:http://pan.baidu.com/s/1jIt6UlK
- eclipse安装Spring Tool Suite 各个版本的方法
有时候spring官网上找不到与我们当前eclipse对应的spring插件,用URL的方式安装费时又费力,那么如何下载对应的spring插件呢? 先到插件页面,然后点击“原先的插件版本” 显示出这个 ...
- poj 1064(二分答案)
传送门:Problem 1064 https://www.cnblogs.com/violet-acmer/p/9793209.html 题意: 有N条绳子,长度分别为 length[1,2,3,.. ...
- laravel redis 删除指定前缀的 key
// 前缀 $prefix = 'abc'; // 需要在前面连接上应用的缓存前缀 $keys = app('redis')->keys(config('cache.prefix') . $pr ...
- 【leetcode】 Merge Intervals
Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example,Given ...
- Python基础【day03】:文件操作(七)
零.本节内容 1.文件常用操作汇总 2.打开文件 3.操作文件 4.关闭文件 一.文件常用操作汇总 二.打开文件 1.普通打开模式 r,英文:read,只读模式(默认) w,英文:write,只写模式 ...
- .Net MVC 当前上下文中不存在名称“Style”
遇到了这种问题,最后居然是我拼写错误了... 当然也有其他原因 http://blog.csdn.net/bianchao1/article/details/69666347 按照上面这篇博客的方法先 ...
- Object.keys()返回对象的属性
<script> // 传入对象,返回属性名 let obj = { 'a': '123', 'b': '456' } console.log(Object.keys(obj)) //[& ...
- Math.random()和UUID.randomUUID().toString()性能对比【纯原】
Math.random()和UUID.randomUUID().toString()性能对比 不言而喻,因为Math.random()不需要保证唯一性,所做的操作远比UUID消耗更小的性能, 在部分要 ...