309587: CF1703B. ICPC Balloons

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:4 Solved:0

Description

ICPC Balloons

题意翻译

在一场比赛中,有 $26$ 道题目和很多个团队,题目标号分别为 `A` 到 `Z`。每当一道题目被第一次解决,该团队获得 $2$ 个气球,否则获得 $1$ 个气球。 现在给出一个字符串,代表题目被解决的顺序,字符串第 $i$ 个字符 $S_i$ 代表题目 $S_i$ 被解决。求所有团队获得的气球总数。

题目描述

In an ICPC contest, balloons are distributed as follows: - Whenever a team solves a problem, that team gets a balloon. - The first team to solve a problem gets an additional balloon. A contest has 26 problems, labelled $ \textsf{A} $ , $ \textsf{B} $ , $ \textsf{C} $ , ..., $ \textsf{Z} $ . You are given the order of solved problems in the contest, denoted as a string $ s $ , where the $ i $ -th character indicates that the problem $ s_i $ has been solved by some team. No team will solve the same problem twice.Determine the total number of balloons that the teams received. Note that some problems may be solved by none of the teams.

输入输出格式

输入格式


The first line of the input contains an integer $ t $ ( $ 1 \leq t \leq 100 $ ) — the number of testcases. The first line of each test case contains an integer $ n $ ( $ 1 \leq n \leq 50 $ ) — the length of the string. The second line of each test case contains a string $ s $ of length $ n $ consisting of uppercase English letters, denoting the order of solved problems.

输出格式


For each test case, output a single integer — the total number of balloons that the teams received.

输入输出样例

输入样例 #1

6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES

输出样例 #1

5
2
6
7
8
17

说明

In the first test case, $ 5 $ balloons are given out: - Problem $ \textsf{A} $ is solved. That team receives $ 2 $ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $ \textsf{A} $ . - Problem $ \textsf{B} $ is solved. That team receives $ 2 $ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $ \textsf{B} $ . - Problem $ \textsf{A} $ is solved. That team receives only $ 1 $ balloon, because they solved the problem. Note that they don't get an additional balloon because they are not the first team to solve problem $ \textsf{A} $ . The total number of balloons given out is $ 2+2+1=5 $ .In the second test case, there is only one problem solved. The team who solved it receives $ 2 $ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $ \textsf{A} $ .

Input

题意翻译

在一场比赛中,有 $26$ 道题目和很多个团队,题目标号分别为 `A` 到 `Z`。每当一道题目被第一次解决,该团队获得 $2$ 个气球,否则获得 $1$ 个气球。 现在给出一个字符串,代表题目被解决的顺序,字符串第 $i$ 个字符 $S_i$ 代表题目 $S_i$ 被解决。求所有团队获得的气球总数。

Output

**题目大意:**
在ICPC比赛中,共有26道题目,题目标号为A到Z。当一个团队首次解决一个问题时,他们会获得2个气球;如果不是首次解决,则获得1个气球。给定一个字符串,表示题目被解决的顺序,其中第i个字符$S_i$代表题目$S_i$被解决。需要计算所有团队获得的气球总数。

**输入输出数据格式:**
- **输入格式:**
- 第一行包含一个整数$t$($1 \leq t \leq 100$),表示测试用例的数量。
- 每个测试用例的第一行包含一个整数$n$($1 \leq n \leq 50$),表示字符串的长度。
- 每个测试用例的第二行包含一个长度为$n$的由大写英文字母组成的字符串$s$,表示题目被解决的顺序。
- **输出格式:**
- 对于每个测试用例,输出一个整数,表示团队总共获得的气球数量。

**输入输出样例:**
- **输入样例 #1:**
```
6
3
ABA
1
A
3
ORZ
5
BAAAA
4
BKPT
10
CODEFORCES
```
- **输出样例 #1:**
```
5
2
6
7
8
17
```**题目大意:** 在ICPC比赛中,共有26道题目,题目标号为A到Z。当一个团队首次解决一个问题时,他们会获得2个气球;如果不是首次解决,则获得1个气球。给定一个字符串,表示题目被解决的顺序,其中第i个字符$S_i$代表题目$S_i$被解决。需要计算所有团队获得的气球总数。 **输入输出数据格式:** - **输入格式:** - 第一行包含一个整数$t$($1 \leq t \leq 100$),表示测试用例的数量。 - 每个测试用例的第一行包含一个整数$n$($1 \leq n \leq 50$),表示字符串的长度。 - 每个测试用例的第二行包含一个长度为$n$的由大写英文字母组成的字符串$s$,表示题目被解决的顺序。 - **输出格式:** - 对于每个测试用例,输出一个整数,表示团队总共获得的气球数量。 **输入输出样例:** - **输入样例 #1:** ``` 6 3 ABA 1 A 3 ORZ 5 BAAAA 4 BKPT 10 CODEFORCES ``` - **输出样例 #1:** ``` 5 2 6 7 8 17 ```

加入题单

算法标签: