Codeforces Round #513 A. Phone Numbers(水题)

 

题目链接:http://codeforces.com/contest/1060/problem/A

       题意是输入n个数字,然后问这n个数字最多能组成多少个手机号,手机号是11位的,而且必须要8开头。

       思路很简单,求出n/11和8的个数的最小值就好了...


AC代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string str;
	cin>>n;
	cin>>str;
	int len = str.length();
	int ans = 0;
	for(int i=0;i<len;i++){
		if(str[i] == '8'){
			ans++;
		}
	}
	int x = n / 11;
	cout<<min(x,ans)<<endl;
	return 0;
}

 

全部评论

相关推荐

2025-12-27 22:21
门头沟学院 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
2025-11-27 10:04
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务