日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

codeforces 1060a(思维水题)

發布時間:2023/12/15 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces 1060a(思维水题) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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≤n≤100).

The second line contains a string of n digits (characters “0”, “1”, …, “9”) s1,s2,…,sn. 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.

Examples
inputCopy
11
00000000008
outputCopy
1
inputCopy
22
0011223344556677889988
outputCopy
2
inputCopy
11
31415926535
outputCopy
0
Note
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.
完全就是一道思維水題,想明白就好了。。有可能有5個8,但是可能就只能組成兩個電話號碼。所以就只能是2。但是呢,如果可以組成5組電話號碼,不過只有2個8,那也只能組成2個。找這之間的兩者的最小值就好了。
代碼如下:

#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std;int n; char s[101];int main() {while(scanf("%d",&n)!=EOF){int count=0;scanf("%s",s); for(int i=0;i<n;i++){if(s[i]=='8') count++;}int ans=n/11;cout<<min(count,ans)<<endl; }return 0; }

多鍛煉點思維,對a題有好處的。
努力加油a啊,(o)/~

總結

以上是生活随笔為你收集整理的codeforces 1060a(思维水题)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。