3 solutions

  • 0
    @ 2024-9-27 20:56:49
    #include<stdio.h>
    #include<math.h>
    int a[10];
    int main()
    {
    	int n;
    	scanf("%d",&n);
    	while(n--)
    	{
    		int u;
    		scanf("%d",&u);
    		u = u%8;
    		a[u]++;
    	}
    	long long sum = 0;
    	if(a[4] >=2)
    	{
    		long pp  = 0;
    	for(int i = a[4]-1;i >= 1;i--)
    	{
    		pp+=i;
    	}
    	sum += pp;
    	}
    	
    	if(a[0] >= 2)
    	{
    		long oo = 0;
    	  for(int i = a[0]-1;i >= 1;i--)
    	   {
    		oo+=i;
    	   }
    	   sum += oo;
    	}
    	
    	
    	for(int i = 1;i < 4;i++)
    	{
    		long long d = a[i]*a[8-i];
    		
    		sum = sum + d;
    	}
    	printf("%lld",sum);
    	return 0;
    }
    
    

    Information

    ID
    6977
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    (None)
    # Submissions
    225
    Accepted
    12
    Uploaded By