3 solutions

  • 0
    @ 2024-4-10 17:30:05
    #include <iostream>
    using namespace std;
    
    int64_t Add(int num)
    {
       int64_t sum = 0;
       for (int i = 0; i < num; i++)
           sum += i;
       
       return sum;
    }
    
    int main()
    {
       int n;
       cin >> n;
       int num;
       int A = 0, B = 0, C = 0, D = 0,
             E = 0, F = 0, G = 0, H = 0;
       int64_t  count = 0;
    
       for (int i = 0; i < n; i++)
       {
    	cin >> num;
    	switch (num % 8)
    	{
    		case 1:A++; break;
    		case 2:B++; break;
    		case 3:C++; break;
    		case 4:D++; break;
    		case 5:E++; break;
    		case 6:F++; break;
    		case 7:G++; break;
    		case 0:H++; break;
            }
       }
       count = A * G + B * F + C * E 
                    + Add(D)+Add(H);
    
       cout << count;
    
       return 0;
    }
    

    Information

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