A. Problemsolving Log

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Monocarp is participating in a programming contest, which features 2626 problems, named from 'A' to 'Z'. The problems are sorted by difficulty. Moreover, it's known that Monocarp can solve problem 'A' in 11 minute, problem 'B' in 22 minutes, ..., problem 'Z' in 2626 minutes.

After the contest, you discovered his contest log — a string, consisting of uppercase Latin letters, such that the i�-th letter tells which problem Monocarp was solving during the i�-th minute of the contest. If Monocarp had spent enough time in total on a problem to solve it, he solved it. Note that Monocarp could have been thinking about a problem after solving it.

Given Monocarp's contest log, calculate the number of problems he solved during the contest.

Input

The first line contains a single integer t� (1≤t≤1001≤�≤100) — the number of testcases.

The first line of each testcase contains a single integer n� (1≤n≤5001≤�≤500) — the duration of the contest, in minutes.

The second line contains a string of length exactly n�, consisting only of uppercase Latin letters, — Monocarp's contest log.

Output

For each testcase, print a single integer — the number of problems Monocarp solved during the contest.

Example

input

Copy


  

3

6

ACBCBC

7

AAAAFPC

22

FEADBBDFFEDFFFDHHHADCC

output

Copy

3
1
4

解题说明:此题是一道数学题,由于每个字母对应的解题时间是确定的,那么只需要统计解题日志中各个字母出现的次数,A至少出现1次,才代表解答了这一题,依次类推。B至少出现2次,C至少出现3次。遍历后统计字母出现的次数即可。

#include<stdio.h>
int num[28];

int main()
{
	int t, i, n;
	scanf("%d", &t);
	char str[500];
	while (t--)
	{
		int cnt = 0;
		scanf("%d", &n);
		scanf("%s", str);
		for (i = 0; i < n; i++)
		{
			num[str[i] + 1 - 'A']++;
		}
		for (i = 1; i <= 26; i++)
		{
			if (num[i] >= i)
			{
				cnt++;
			}
			num[i] = 0;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-29 02:38:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-29 02:38:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-29 02:38:01       87 阅读
  4. Python语言-面向对象

    2024-01-29 02:38:01       96 阅读

热门阅读

  1. 关于css 的基础试题

    2024-01-29 02:38:01       53 阅读
  2. Spring Boot更换Spring fox为Springdoc

    2024-01-29 02:38:01       49 阅读
  3. 组装无人机需要哪些工具?

    2024-01-29 02:38:01       48 阅读
  4. OkHttp的理解和使用

    2024-01-29 02:38:01       53 阅读
  5. 四、MySQL之增删改

    2024-01-29 02:38:01       46 阅读
  6. 临床医疗大数据治理框架

    2024-01-29 02:38:01       56 阅读
  7. Hive之set参数大全-17

    2024-01-29 02:38:01       42 阅读
  8. 从c到c++——6:auto

    2024-01-29 02:38:01       53 阅读
  9. Python NLP深度学习进阶:自然语言处理

    2024-01-29 02:38:01       40 阅读
  10. NET高级面试指南专题二【泛型】

    2024-01-29 02:38:01       49 阅读
  11. Flask介绍和优势

    2024-01-29 02:38:01       57 阅读