The first 1 That's ok ：1 Number N, Represents an array A The length of (1 <= N <= 100000).

The first 2 - N + 1 That's ok ： Each row 1 Number A[i]（1 <= A[i] <= 10^9).

Output fun(A) Calculated results of .

3

1 4 1

4 The laws of mathematics , Only 1 and 2 The amount of money has an impact on the final result /

#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cmath>

#include<vector>

using namespace std;

typedef long long LL;

#define M 1000000007

/*

1 The effect of ,[(1+n)/n]

n=1 sum+=2 n>1 sum+=1

2 n =1,sum+=1,n=2,sum+=1,n>2,sum+=0;

3 [(3+n)/3*n] 1_1 2_0 3_0 4_0

4 [(4+n)/4*n] 1_1 2_0 3_0 4_0

Only 1

----

set up n1,n2,n-n1-n1 Respectively 1 The number of ,2 The number of , Other numbers

The final result is equal to

2*(n1*(n1-1)/2) //1 and 1 Between

+ n2*(n2-1)/2

+ n1*(n-n1-n2)

*/

int main()

{

vector<LL> v;

LL n,t,cnt=,num=;

scanf("%lld",&n);

for(LL i=;i<n;i++)

{

scanf("%lld",&t);

if(t==)

cnt+=n-;

else if(t==)

num++;

}

printf("%lld\n",cnt+num*(num-)/);

return ;

}

## Pairwise Sum and Divide 51nod More articles about

- 51nod 1305：Pairwise Sum and Divide
1305 Pairwise Sum and Divide Title source : HackerRank Base time limit :1 second Space restriction :131072 KB The score is : 5 difficulty :1 Level algorithm problem Collection Focus on There is such a passage ...

- 51nod1305 Pairwise Sum and Divide
Topic link :51nod 1305 Pairwise Sum and Divide After reading the question, I didn't even think about it, so I did it directly ,AC And then suddenly it came to me ... Floor( (a+b)/(a*b) )=Floor( ( ...

- 1305 Pairwise Sum and Divide
1305 Pairwise Sum and Divide Title source : HackerRank Base time limit :1 second Space restriction :131072 KB The score is : 5 difficulty :1 Level algorithm problem There is such a program ,fun Would be right ...

- 1289 Big fish eat small fish 1305 Pairwise Sum and Divide 1344 Go to the grid 1347 Rotate string 1381 Coin game
1289 Big fish eat small fish Yes N Each fish is different in position and size , They are following X Axis swimming , Some left , Some are right . The speed of swimming is the same , When two fish meet, the big one will eat the small one . From left to right, give the size and direction of each fish (0 Indicating left ,1 Indicating right ...

- 1305 Pairwise Sum and Divide（ mathematics , law ）
HackerRank 1305 Pairwise Sum and Divide There is such a program ,fun I'll do an array of integers A Is evaluated , among Floor Indicates rounding down : fun(A) sum = ...

- 51nod P1305 Pairwise Sum and Divide —— Thinking questions
For a long time しぶり! An interesting question I found , I haven't found the rule after thinking for a long time , It turned out to be a question of thinking ..( With the help of the big guy ) Original title stamp >>https://www.51nod.com/onlineJudge/ques ...

- 51Nod 1305 Pairwise Sum and Divide | thinking mathematics
Output Output fun(A) Calculated results of . Input Example 3 1 4 1 Output Example 4 first try: #include "bits/stdc++.h" using ...

- [51nod] 1305 Pairwise Sum and Divide mathematics
There is such a program ,fun I'll do an array of integers A Is evaluated , among Floor Indicates rounding down : fun(A) sum = 0 for i = 1 to A.length for j = ...

- 51nod 1305 Pairwise Sum and Divide
There is such a program ,fun I'll do an array of integers A Is evaluated , among Floor Indicates rounding down : fun(A) sum = 0 for i = 1 to A.length for j = ...

## Random recommendation

- iOS UIWebView Interaction with web pages (OC Mid tone execution JS)
UIWebView Interaction with web pages (OC Mid tone execution JS)- (void)viewDidLoad{[super viewDidLoad];// 1.webViewUIWebView *webView = [[ ...

- LR monitor Windows resources
1. Monitoring preparation : The monitor : 1) install tcp/ip Under the agreement netbios 2) use administrator Sign in The monitored party : 1) Monitored Windows Start two services : Remote ProcedureCal ...

- kvm Clone virtual machine
Two steps : The first step is to export XML: [root@ok ~]# virsh dumpxml centos02 >12c.xml Step 2 disk file [root@ok virhost]# cp centos02 ...

- jQuery Plug in comprehensive application ( One ) register
One . Introduce Registration and login are functions that every website with a little bit of scale should have . The login function is similar to the registration function , It's simpler than the registration function . So this article is about registration jQuery Plug in applications . jQuery Plug in is very easy to use , If only according to jQ ...

- JAVA aggregate LIST MAP SET Detailed explanation
1. Introduction to collection framework We know , The advantage of a computer is that it processes a lot of data , In programming development , To deal with a lot of data , Must have the corresponding storage structure , The array learned before can be used to store and process a large number of data of the same type , But through the exercises above , Will find ...

- use RedisLive monitor Redis service
1. Basic environment installation https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_h ...

- ( original )foef matters needing attention
Original content , Please indicate the original address for reprint Let's take a look at the following code first // Get file size DWORD Get_File_Size(const char* m_FilePath) { unsigned long size ...

- C Language describes the implementation and operation of stack （ Linked list implementation ）
#include<stdio.h> #include<malloc.h> #include<stdlib.h> typedef int Elementtype; / ...

- 【 Luogu p2142】 High precision subtraction
The high precision subtraction didn't go through the first time High precision subtraction [ Portal ] Rogue algorithm tag : In a word, the technology is all in high precision . The attached code : #include<iostream> #include<cstdio> #in ...

- [vuejs] vue2.0-layer-mobile Moving end shell layer
vue2.0-layer-mobile Moving end shell layer This component upgrade supports slot Content distribution capabilities , A bullet layer for high custom content style Installation method npm install vue2-layer-mobile -S initialization i ...