CF1703B.ICPC Balloons

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 A\textsf{A} , B\textsf{B} , C\textsf{C} , ..., Z\textsf{Z} . You are given the order of solved problems in the contest, denoted as a string ss , where the ii -th character indicates that the problem sis_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 tt ( 1t1001 \leq t \leq 100 ) — the number of testcases.

The first line of each test case contains an integer nn ( 1n501 \leq n \leq 50 ) — the length of the string.

The second line of each test case contains a string ss of length nn 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, 55 balloons are given out:

  • Problem A\textsf{A} is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem A\textsf{A} .
  • Problem B\textsf{B} is solved. That team receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem B\textsf{B} .
  • Problem A\textsf{A} is solved. That team receives only 11 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 A\textsf{A} .

The total number of balloons given out is 2+2+1=52+2+1=5 .In the second test case, there is only one problem solved. The team who solved it receives 22 balloons: one because they solved the problem, an an additional one because they are the first team to solve problem A\textsf{A} .

首页