Accepted solution

1060A - Phone Numbers.

Open original problem
Source code

#include<bits/stdc++.h>

#include<string>

using namespace std;

int main()

{

   int n,i=0;

   int count=0;

   cin>>n;

   if(n<11)

   {

    cout<<0<<endl;

    return 0;

   }

    string num;

   cin>>num;

   while(i<n)

   {

     int temp;

    char c = num[i];

     temp= (int)c-48; ///convert char to int

     if(temp==8)

     {

      count++;

     }

     i++;

   }

   if(count==0)

   {

    cout<<0<<endl;

    return 0;

   }

   if(n/11<=count)

   {

       cout<<n/11<<endl;

   }

   else if(count>=1 && n>=11)

   {

       cout<<count<<endl;

   }

   else

    {

        cout<<0<<endl;

    }

}
Join the discussion

Add your comment