题目链接:http://codeforces.com/problemset/problem/567/C C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was on…
题目链接:https://codeforces.com/problemset/problem/567/C 题意: 给出长度为 $n$ 的序列 $a[1:n]$,给出公比 $k$,要求你个给出该序列中,长度为 $3$ 的等比子序列的数目. 题解: 首先倒着遍历,用map记录曾经出现过的每个数字的出现次数,然后再用另一个map来记录曾经出现过的所有满足 $(x,kx)$ 的二元组的数目,最后就直接维护答案即可. AC代码: #include<bits/stdc++.h> #define IO (i…
Geometric Progression Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 567C Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only t…
题目大概说给一个整数序列,问里面有几个包含三个数字的子序列ai,aj,ak,满足ai*k*k=aj*k=ak. 感觉很多种做法的样子,我想到这么一种: 枚举中间的aj,看它左边有多少个aj/k右边有多少个aj*k,两边个数的乘积就是答案的一部分贡献. 而左边各个数字的个数和右边各个数字可以用两个map维护,一边枚举一边删除或插入. #include<cstdio> #include<map> #include<algorithm> using namespace std…
input n,k 1<=n,k<=200000 a1 a2 ... an 1<=ai<=1e9 output 数组中选三个数,且三个数的下标严格递增,凑成形如b,b*k,b*k*k的种数 做法:先将可以作为第三个数的数放到map中,然后再扫一遍依次统计map中的数作为第三个数的种数,第二个数的种数,第三个数的种数 #include<cstdio> #include<map> struct node { int b;//a[i]作为i1的种数 long lo…
C. Geometric Progression Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/C Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length…
题目大意:输入两个整数 n 和 k ,接下来输入n个整数组成的序列.求该序列中三个数 满足条件的子串个数(要求字串由三个整数a,b,c组成,其中 c = k * b = k * k * a). 思路:枚举中间的数,然后分别求出前面和后面满足条件的数的个数,将两数相乘,然后累加积即可. 由于题目中给出的数据范围较大,且有负数,故用MAP来影射输入的序列中的每个元素. 代码: #include<iostream> #include<cstdio> #include<cstring…
题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 1:07:18 * File Name :C.cpp *******************************************…
time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output Problem Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progression…
C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions o…