Codeforces Round #Pi (Div. 2) C

Source: Internet
Author: User

Test instructions: give you a sequence, and K, choose 3 numbers, subscript strictly increment, meet the increment of geometric series, equal to K

Idea: Count the number of all numbers first, enumerate geometric series of the middle number A, calculate the number of a*k after a, the number of a/k before a, multiply

(Playing a game of brain residue, but also think of what, love Disabled)

#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 namespaceStd;typedefLong Longll;typedef unsignedLong LongULL;ConstLL MOD = 1e7 +7;ConstLL MAXN = 1e5 +131; Map<LL,LL>Num1;map<LL,LL>Num2; LL LINE[MAXN<<1]; LL n,k;intMain () { while(Cin >> N >>K) {LL Sum=0; Num1.clear ();        Num2.clear ();  for(inti =1; I <= N; ++i) Cin>> Line[i], Num1[line[i]] + +;  for(inti = 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; ElseR = num2[line[i]*J]; L= Num1[line[i]/K]-num2[line[i]/K]; Sum+ = (L *R); }} cout<< Sum <<Endl; }}

Codeforces Round #Pi (Div. 2) C

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.