CodeForces 567C Geometric Progression】的更多相关文章

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…
题目链接: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…
题目大概说给一个整数序列,问里面有几个包含三个数字的子序列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…
题目大意:输入两个整数 n 和 k ,接下来输入n个整数组成的序列.求该序列中三个数 满足条件的子串个数(要求字串由三个整数a,b,c组成,其中 c = k * b = k * k * a). 思路:枚举中间的数,然后分别求出前面和后面满足条件的数的个数,将两数相乘,然后累加积即可. 由于题目中给出的数据范围较大,且有负数,故用MAP来影射输入的序列中的每个元素. 代码: #include<iostream> #include<cstdio> #include<cstring…
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: 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…
题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 1:07:18 * File Name :C.cpp *******************************************…
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…
Geometric Progression Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=628&pid=1001 Description 判断一个数列是否为等比数列. 在数学中,等比数列,是一个数列,这个数列中的第一项之后的每一项是前一项乘上一个固定的非零实数(我们称之为公比).比如,数列 2, 6, 18, 54,…
Problem Description Determine whether a sequence is a Geometric progression or not. In mathematics, a **geometric progression**, also known , , , , ... . Similarly , , /. Examples of a geometric sequence are powers rk of a fixed number r, such as 2k…
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…
题目链接:http://codeforces.com/problemset/problem/382/C 题目意思:给定一个序列,问是否可以通过只插入一个数来使得整个序列成为等差数列,求出总共有多少可能的情况,并输出这些数. n = 1 . n = 2 和 整个序列是常数列 的情况比较容易判断.不过要注意n = 2的时候,也需要判断两个数之间是否也可以通过插入一个数来构成等差数列. 关键是讨论n>=3的情况.预处理:把整个输入序列从小到大排序.之后,得到公差是第一要务!如果可以从中插入一个数(这时…
Geometrical Progression n == 1的时候答案为区间长度, n == 2的时候每两个数字都可能成为答案, 我们只需要考虑 n == 3的情况, 我们可以枚举公差, 其分子分母都在sqrt(1e7)以内, 然后暴力枚举就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL,…
题目链接:http://codeforces.com/problemset/problem/1114/E 题意: 交互题,有一个 $n$ 个整数的打乱顺序后的等差数列 $a[1 \sim n]$,保证公差为正整数,你可以询问不超过 $60$ 次来找到该等差数列的首项和公差. 你可以做的询问有两种: 1.询问是否存在某个数字大于 $x$. 2.询问序列中第 $i$ 个数是多少. 题解: 首先可以用二分的方式找到这个等差数列的最大值,由于 $a[i] \in [0,1e9]$,所以最多 $30$ 次…
Codeforces 题目传送门 & 洛谷题目传送门 u1s1 感觉此题思维难度不太大,不过大概是细节多得到了精神污染的地步所以才放到 D1E 的罢((( 首先我们对所有 \(a_i,b_i\) 分解质因数并将它们全部质因子拎出来编个号 \(1,2,3,\cdots,m\)--这样的质因子个数肯定不会超过 \(2n\omega(a_i)\).我们记 \(ap_{i,j}\) 表示 \(a_i\) 中标号为 \(j\) 的质因子出现的次数,\(bp_{i,j}\) 表示 \(b_i\) 中标号为…
题意:给出一个大数数列,问是不是等比数列. 解法:拿java大数搞,注意全是0的情况也是Yes.我把公比用分数表示了,灰常麻烦,题解说只要判a[i - 1] * a[i + 1] == a[i] * a[i]就可以了,涨姿势了. 代码: import java.math.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanne…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5429 题意:给一段长度不超过100的每个数字(可以是浮点数)的长度不超过1000的序列,问这个序列是否是一个等比数列: 等比数列以第一个数为首项,并且r != 0,一个坑点 之前我写的hdu1002的高精度在这里不能用的,因为我的高精度里面还只能是正整数,这时直接使用java的BigDecimal即可: ps:特别要注意 1 0这个序列不是等比序列!还有 大数比较是否相等,要使用函数,不能使用==,…
题目传送门 题意:判断是否是等比数列 分析:高精度 + 条件:a[i] * a[i+2] == a[i+1] * a[i+1].特殊情况:0 0 0 0 0是Yes的,1 2 0 9 2是No的 代码: /************************************************ * Author :Running_Time * Created Time :2015-9-5 20:06:46 * File Name :C.cpp **********************…
题意:给出一个长度为n的序列,表示有n张卡片,上面的数字,现在还有一张卡片,上面没有数字,问说可以写几种数字在这张卡片上面, 使得n+1张卡片上的数字可以排列成一个等差数列,有无限多种时输出-1. 析:首先排序是肯定的,然后再分成几种,如果只有一个数,那么就一定是-1,如果是两个数时,在前面和后面一定可以加一个,这个也要注意相等的情况, 然后再考虑中间的情况,如果它们的绝对差是偶数,那么中间也可以再放一个,再就是大于等于3个数时候,这个也要考虑是不是全相等,然后再考虑这个 序列是不是可以加一个数…
567A Lineland Mail题意:一些城市在一个x轴上,他们之间非常喜欢写信交流.送信的费用就是两个城市之间的距离,问每个城市写一封信给其它城市所花费的最小费用和最大的费用. 没什么好说的.直接做.特判最左边的和最右边的.其它的最小值在相邻的城市取,最大的在两边的城市与本城市取最大值. 代码: #include <set> #include <map> #include <queue> #include <stack> #include <de…
C. DZY Loves Fibonacci Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 …
A. Lineland Mail time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordi…
A. IQ Test time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. N…
A题: 题目地址:Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm> #include <set> #include <queue> #include…
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
原题链接 Problem Description You are a "Problem Killer", you want to solve many problems. Now you have n problems, the i-th problem's difficulty is represented by an integer ai (1≤ai≤109).For some strange reason, you must choose some integer l and r…
List of mathematical abbreviations From Wikipedia, the free encyclopedia 数学缩写列表 维基百科,自由的百科全书 This article is a listing of abbreviated names of mathematical functions, function-like operators and other mathematical terminology. 这篇文章是一个数学函数,类似于函数的操作符和其…
<英语口译全真试题精解> GPA 3.5 (MTI)  (CPA) ( GRE )  1350分+3.5以上 SAT ( TOEFL )  100分以上 TOEIC BEC (剑桥商务英语) ( GMAT ) x IELTS CET ( TSE ) GRE计算机专项考试 英语中高级口译 GRE Top 12 words anomaly assuage enigma equivocal erudite fervid lucid opaque placate precipitate prodiga…