//我觉得这题好像跟我理解的不太一样啊T ^ T,有点郁闷

Description

There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that

1. 1 ≤ i, j ≤ N

2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.

Input

The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.

Output

Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.

Sample Input

Input

great10

Output

7

Input

aaaaaaaaaa

Output

100

 1 #include<stdio.h>
 2
 3 #include<string.h>
 4
 5
 6
 7 int t[100000];
 8
 9
10
11 int main()
12
13 {
14
15 char s[100000];
16
17 while(gets(s))
18
19 {
20
21 double sum=0;
22
23 int l=strlen(s);
24
25 memset(t,0,sizeof(t));
26
27 for(int i=0;i<l;i++)
28
29 {
30
31 t[s[i]]++;
32
33 }
34
35 for(int i='0';i<='z';i++)
36
37 {
38
39 sum+=(double)t[i]*t[i];
40
41 }
42
43 printf("%.0lf\n",sum);
44
45 }
46
47 return 0;
48
49 } 

View Code

转载于:https://www.cnblogs.com/awsent/p/4266900.html

(寒假CF)Choosing Symbol Pairs相关推荐

  1. Choosing Symbol Pairs

    Description There is a given string S consisting of N symbols. Your task is to find the number of or ...

  2. cf 1569D - Inconvenient Pairs

    cf 1569D - Inconvenient Pairs (由于感觉代码很优美想记录下来,当然代码重复的部分写成函数就更好了 题目链接 方法:按x排序,顺次更新记录某列(y)的cnt, y同理 #i ...

  3. Codeforces--50B--Choosing Symbol Pairs

    题目描述: There is a given string S consisting of N symbols. Your task is to find the number of ordered ...

  4. 【题解】CF#403 D-Beautiful Pairs of Numbers

    这题还挺对胃口的哈哈~是喜欢的画风!回家路上一边听歌一边想到的解法,写出来记录一下-- 首先,由于 \(b_{k} < a_{k + 1}\) ,所以我们可以看作是在一个长度为 n 的序列上选择 ...

  5. 14. Setting Ta and RTO【设置Ta和RTO】

    原文链接:https://datatracker.ietf.org/doc/html/rfc8445#section-14 14. Setting Ta and RTO[设置Ta和RTO] 14.1. ...

  6. 【Linux】GCC程序开发工具(下)

    00. 目录 文章目录 00. 目录 01. GCC的二进制工具 02. objdump 03. objcopy命令 04. 总结 05. 附录 01. GCC的二进制工具 objdump 显示目标文 ...

  7. 【Shell】mksh运行分析

    mksh运行分析 Shell shell,壳子,即操作系统的壳子.这层壳子套在操作系统上,为用户提供与操作系统的交互手段. 操作系统的交互方式一般有,图形化交互(GUI)和命令行交付(CLI,comm ...

  8. python与财务报表_雅虎财经Python网站刮板关键统计数据和财务报表

    我不相信你用来提取信息的方法是最可靠的方法,但是我改变了你的代码来捕捉你需要的信息.我更新了正则表达式以检查括号,并在末尾添加了一个节来替换import urllib import re keysta ...

  9. NLP 学习笔记 3: Data preparation, tokenization, and filtering.

    tokenization tokenization是对一串输入字符进行划分和分类的任务,其输出的token将会被用于其他处理. Data Preparation read a dataset 定义一个 ...

最新文章

  1. 查看tensorflow安装版本
  2. Jmeter使用jp@gc-stepping thread group做性能测试
  3. 5.MySQL Cluster(MySQL集群)
  4. VC++使用MCI播放音频文件
  5. Java分割由多个空白字符连接的字符串
  6. awk 系列Part5:如何使用 awk 复合表达式
  7. debug内exe文件复制到桌面无法打开_Diffinity.轻量级的文件|文本对比工具
  8. linux nslcd服务,CentOS 6通过ldap集成AD域账号(nslcd方式)
  9. pytorch 图像增强
  10. Mcad学习笔记之异步编程(AsyncCallback委托,IAsyncResult接口,BeginInvoke方法,EndInvoke方法的使用小总结)...
  11. 环境变量查看修改工具 RapidEE(Rapid Environment Editor)
  12. VS2010使用教程(使用VS2010编写C语言程序)
  13. GNS3+JunOS
  14. mi5splus android9,小米MIUI 9.5国际版稳定版开始推送:超30款机型将获更新
  15. 上海市五险一金及税后工资计算器
  16. MSM8260,OMAP4430,TEGRA2,EXYNOS 4210详细分析
  17. 神经网络学习——第一个代码学习
  18. 如何防止条码流水号打印出现重码漏码错码的防呆检错系统?
  19. 使用刻录机时的注意事项
  20. 漫谈测试成长之探索——测试用例评审

热门文章

  1. 未解决-hive之drop 表分区失败
  2. C#语言实现定时开启或禁用网卡小程序
  3. jQuery-H5-css3转盘抽奖-遁地龙卷风
  4. iOS沙盒目录结构解析
  5. ./dmitry -p ip或者域名 -f -b
  6. Spark之伪分布式搭建、伪分布式Hadoop、Hive安装
  7. 不学无数——SpringBoot入门Ⅷ
  8. 除了Open Day,Nibiru与DigiArtist来CJ 搞事情了
  9. perl中Net::FTP帮助文档
  10. [转] Apache日志分析常用Shell命令