# A 小G数数

2019/03/09 01:25

/**
/*@author victor
/*language c++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[505];
int main(){
int n;
cin >> n;
ll num = 0;
ll sum = 0;
for(int i = 1 ; i <= n ; i++)
cin >> a[i];
for(int i = 1; i <= n - 3 ; i++ )
for(int j = i + 1; j <= n - 2; j++  )
if(a[i] < a[j]){
num = 0;
for(int k = n; k > j ; k--){
if(a[k] > a[j]) num ++;
if(a[k] < a[j] && a[k] > a[i]) sum += num;
}
}
cout << sum << endl;
return 0;

}

/**
/*@author victor
/*language c++
*/
#include <iostream>
using namespace std;
typedef long long ll;

int A[501];

int main()
{
int n;

cin>>n;

for( int i = 1 ; i <= n ; i ++)
{
cin >> A[i];
}

ll s = 0;

int x = n - 3;

int y = n - 2;

int z = n - 1;

for( int a = 1 ; a <= x ; a ++)
{
for(int b = a + 1 ; b <= y ; b ++)
{
if( A[b] <= A[a])

continue;

for(int c = b + 1 ; c <= z ; c ++)
{
if( A[c] <= A[a] || A[c] >= A[b])

continue;

for(int d = c + 1 ; d <= n ; d ++)
{
if( A[d] <= A[b])

continue;

else s ++;
}
}
}
}

cout << s ;

return 0;
}

0
0 收藏

0 评论
0 收藏
0