Canvas Frames

    xiaoxiao2021-12-14  28

    Description

    Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.

    Nicholas has n sticks whose lengths equal a1, a2, ...an. Nicholas does not want to break the sticks or glue them together. To make ah × w-sized frame, he needs two sticks whose lengths equalh and two sticks whose lengths equal w. Specifically, to make a square frame (when h = w), he needs four sticks of the same length.

    Now Nicholas wants to make from the sticks that he has as many frames as possible; to be able to paint as many canvases as possible to fill the frames. Help him in this uneasy task. Note that it is not necessary to use all the sticks Nicholas has.

    Input

    The first line contains an integern (1 ≤ n ≤ 100) — the number of sticks. The second line containsn space-separated integers. The i-th integer equals the length of the i-th stickai (1 ≤ ai ≤ 100).

    Output

    Print the single number — the maximum number of frames Nicholas can make for his future canvases.

    Sample Input

        Input  

    52 4 3 2 3

        Output  

    1

        Input  

    132 2 4 4 4 4 6 6 6 7 7 9 9

        Output  

    3

        Input  

    43 3 3 5

        Output  

    0

     

    #include<stdio.h> int main() {     int n;     int i,j;     int a[102]={0};     int count,count1;     int k;     scanf("%d",&n);     for(i=0;i<n;i++)     {         scanf("%d",&a[i]);     }     count=0;     while(n)     {         k=a[0];         count1=1;         for(i=0;i<n-1;i++)         {             a[i]=a[i+1];         }         n--;         for(i=0;i<=n-1;i++)         {             if(a[i]==k)             {                for(j=i;j<n-1;j++)                {                    a[j]=a[j+1];                }                n--;                count1++;                 i--;             }         }         count+=count1/2;

        }     count=count/2;     printf("%d\n",count);     return 0; }

     

     

    转载请注明原文地址: https://ju.6miu.com/read-972280.html

    最新回复(0)