(寒假CF)Choosing Symbol Pairs
//我觉得这题好像跟我理解的不太一样啊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相关推荐
- Choosing Symbol Pairs
Description There is a given string S consisting of N symbols. Your task is to find the number of or ...
- cf 1569D - Inconvenient Pairs
cf 1569D - Inconvenient Pairs (由于感觉代码很优美想记录下来,当然代码重复的部分写成函数就更好了 题目链接 方法:按x排序,顺次更新记录某列(y)的cnt, y同理 #i ...
- Codeforces--50B--Choosing Symbol Pairs
题目描述: There is a given string S consisting of N symbols. Your task is to find the number of ordered ...
- 【题解】CF#403 D-Beautiful Pairs of Numbers
这题还挺对胃口的哈哈~是喜欢的画风!回家路上一边听歌一边想到的解法,写出来记录一下-- 首先,由于 \(b_{k} < a_{k + 1}\) ,所以我们可以看作是在一个长度为 n 的序列上选择 ...
- 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. ...
- 【Linux】GCC程序开发工具(下)
00. 目录 文章目录 00. 目录 01. GCC的二进制工具 02. objdump 03. objcopy命令 04. 总结 05. 附录 01. GCC的二进制工具 objdump 显示目标文 ...
- 【Shell】mksh运行分析
mksh运行分析 Shell shell,壳子,即操作系统的壳子.这层壳子套在操作系统上,为用户提供与操作系统的交互手段. 操作系统的交互方式一般有,图形化交互(GUI)和命令行交付(CLI,comm ...
- python与财务报表_雅虎财经Python网站刮板关键统计数据和财务报表
我不相信你用来提取信息的方法是最可靠的方法,但是我改变了你的代码来捕捉你需要的信息.我更新了正则表达式以检查括号,并在末尾添加了一个节来替换import urllib import re keysta ...
- NLP 学习笔记 3: Data preparation, tokenization, and filtering.
tokenization tokenization是对一串输入字符进行划分和分类的任务,其输出的token将会被用于其他处理. Data Preparation read a dataset 定义一个 ...
最新文章
- 查看tensorflow安装版本
- Jmeter使用jp@gc-stepping thread group做性能测试
- 5.MySQL Cluster(MySQL集群)
- VC++使用MCI播放音频文件
- Java分割由多个空白字符连接的字符串
- awk 系列Part5:如何使用 awk 复合表达式
- debug内exe文件复制到桌面无法打开_Diffinity.轻量级的文件|文本对比工具
- linux nslcd服务,CentOS 6通过ldap集成AD域账号(nslcd方式)
- pytorch 图像增强
- Mcad学习笔记之异步编程(AsyncCallback委托,IAsyncResult接口,BeginInvoke方法,EndInvoke方法的使用小总结)...
- 环境变量查看修改工具 RapidEE(Rapid Environment Editor)
- VS2010使用教程(使用VS2010编写C语言程序)
- GNS3+JunOS
- mi5splus android9,小米MIUI 9.5国际版稳定版开始推送:超30款机型将获更新
- 上海市五险一金及税后工资计算器
- MSM8260,OMAP4430,TEGRA2,EXYNOS 4210详细分析
- 神经网络学习——第一个代码学习
- 如何防止条码流水号打印出现重码漏码错码的防呆检错系统?
- 使用刻录机时的注意事项
- 漫谈测试成长之探索——测试用例评审