A. Phone Numbers

题意:给一些数字,每个电话号码以8开头,11位,求最多组成多少个号码,重复累加。

#include <bits/stdc++.h>

using namespace std;

const int maxn = 105;
char str[maxn];

int main() {
    int n;
    scanf("%d%s",&n,str);
    int cnt = 0;
    for(int i = 0; i < strlen(str); i++) {
        if(str[i]=='8') cnt++;
    }

    while(cnt) {
        if((n-cnt)>=cnt*10) break;
        cnt--;
    }

    cout<<cnt<<endl;


    return 0;
}
View Code

相关文章:

  • 2021-11-21
  • 2021-11-17
  • 2022-01-11
  • 2022-03-06
  • 2021-09-11
  • 2021-09-22
  • 2022-01-29
猜你喜欢
  • 2021-12-13
  • 2022-12-23
  • 2021-05-18
  • 2022-02-16
  • 2021-04-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案