[Offer收割]编程练习赛14 register

Ended

Participants:574

Verdict:Time Limit Exceeded
Score:70 / 100
Submitted:2017-04-16 12:46:34

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int a[10000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    if(n<4){
        printf("1\n");
        return 0;
    }
    int tot=0;
    for(int i=0;i<n-3;i++){
        for(int j=i+1;j<n-2;j++){
            for(int x=j+1;x<n-1;x++){
                for(int y=x+1;y<n;y++){
                    if((a[i]+a[x])==(a[j]+a[y]))tot+=2;
                    if((a[i]+a[y])==(a[j]+a[x]))tot+=2;
                    if((a[i]+a[j])==(a[x]+a[y]))tot+=2;
                }
            }
        }
    }
    printf("%d\n",tot);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX