码迷,mamicode.com
首页 > 其他好文 > 详细

2018SDIBT_国庆个人第五场

时间:2018-10-05 17:29:39      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:大于   ant   ORC   you   out   输出   pac   att   can   

A - ACodeForces 1060A

Description

Let‘s call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.

For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.

You have $$$n$$$ cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don‘t have to use all cards. The phone numbers do not necessarily have to be distinct.

Input

The first line contains an integer $$$n$$$ — the number of cards with digits that you have ($$$1 \leq n \leq 100$$$).

The second line contains a string of $$$n$$$ digits (characters "0", "1", ..., "9") $$$s_1, s_2, \ldots, s_n$$$. The string will not contain any other characters, such as leading or trailing spaces.

Output

If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.

Sample Input

Input
11
00000000008
Output
1
Input
22
0011223344556677889988
Output
2
Input
11
31415926535
Output
0

Hint

In the first example, one phone number, "8000000000", can be made from these cards.

In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".

In the third example you can‘t make any phone number from the given cards.

题意:问你能组成多少个电话号码 像8xxxxxxxxxx的,给你n个卡片,每个卡片只能用一次或者不用

分析:不用考虑电话号码里具体的排列

1:如果给出的卡片没有8或者卡片数量小于11,直接输出0

2:t=卡片数除以11,如果t的数量大于号码为8的卡片的数量,则输出8的数量,否则输出t

 1 #include<cstdio>
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<cstring>
 5 #include<cmath>
 6 using namespace std;
 7 int main()
 8 {
 9     int n,a[105];
10     char s[105];
11     while(~scanf("%d",&n))
12     {
13         memset(a,0,sizeof(a));
14         scanf("%s",s);
15         for(int i=0;i<n;i++)
16         {
17             a[s[i]-0]++;
18         }
19         if(a[8]==0||n<11)
20             printf("0\n");
21         else
22         {
23             int t=n/11;
24             if(a[8]>t)
25             {
26                 printf("%d\n",t);
27             }
28             else
29                 printf("%d\n",a[8]);
30         }
31     }
32     return 0;
33 }

 

2018SDIBT_国庆个人第五场

标签:大于   ant   ORC   you   out   输出   pac   att   can   

原文地址:https://www.cnblogs.com/LLLAIH/p/9745086.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!