Choosing Symbol Pairs
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 ≤ i, j ≤ N
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
题目很水,就是让你配对,题意也很好理解,注意int不行,会越界,我错了两次就是没有进行好强制转换,看一下我的代码吧
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
using namespace std;
int main()
{char x[100005];int a[50];while(~scanf("%s", x)){memset(a, 0, sizeof(a));int len = strlen(x);for(int i = 0; i < len; i++){if(islower(x[i])) a[x[i] - 'a' + 10]++;else a[x[i] - '0']++;}long long sum = 0;for(int i = 0; i < 36; i++){sum += (a[i] * 1LL *a[i]);}printf("%lld\n", sum);}return 0;
}
Choosing Symbol Pairs相关推荐
- (寒假CF)Choosing Symbol Pairs
//我觉得这题好像跟我理解的不太一样啊T ^ T,有点郁闷 Description There is a given string S consisting of N symbols. Your ta ...
- Codeforces--50B--Choosing Symbol Pairs
题目描述: There is a given string S consisting of N symbols. Your task is to find the number of ordered ...
- 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 显示目标文 ...
- NLP 学习笔记 3: Data preparation, tokenization, and filtering.
tokenization tokenization是对一串输入字符进行划分和分类的任务,其输出的token将会被用于其他处理. Data Preparation read a dataset 定义一个 ...
- oracle subset-superset pairs,Oracle 字符集
1 字符集超集 当一种字符集(字符集A)的编码数值包含所有另一种字符集(字符集B)的编码数值,并且两种字符集相同编码数值代表相同的字符时,则字符集A是字符集B的超级,或称字符集B是字符集A的子集. O ...
- [JavaScript] 好用的 JavaScript Symbol 类型
初识Symbol 什么是Symbol? 可以理解它为一个标识,一般情况下用来解决重名问题. let hd = Symbol('hello,dust.') let edu = Symbol('good ...
- Android Studio – Cannot resolve symbol ‘R’
Android Studio – Cannot resolve symbol 'R' 解决方法: Build -> Clean Project Tools -> Android -> ...
- Pairs Forming LCM LightOJ - 1236
Pairs Forming LCM LightOJ - 1236 题意 问共有多少组数的最大公约数是n 分析 组合数学 ,唯一分解定理 参考代码 int Prime[670000]; const in ...
最新文章
- 独家 | 以国家战略科学家身份,顶级AI学者朱松纯回国,筹建北京通用AI研究院...
- 从1G到5G,从回顾过去到展望未来
- 构建之法阅读笔记06
- golang的WaitGroup
- 微信小程序开发(二)
- 一阶暂态电路三要素法和三种响应
- java stub_Java Stub 研究学习(2)
- Eclipse 构建Maven项目--普通web项目 复制另外一个项目的配置文件导致的问题
- 【工具相关】iOS-Reveal的使用
- oracle 查询有字母,oracle中查询含字母的数据[正则表达式]
- 网吧服务器是起什么作用的,网吧服务器的用途是什么?
- 微软Windows 8 非常实用的12个技巧
- 《阳光下》 ——【传递正反馈】
- java script 菜鸟教程_JavaScript 基础教程
- MSDC 4.3 接口规范(3)
- Babel 学习日记(0)
- UE4粒子在镜头看不到时不显示问题解决
- [转]最速下降曲线:重力场中两点之间曲线更快
- Python爬虫实战:分析《战狼2》豆瓣影评
- spring boot: Whitelabel Error Page(小白的终极解决方案)
热门文章
- EOF-DataScience:数据预处理/特征工程之线性变换—四种特征缩放Scaling算法简介、标准化standardization、归一化Normalization的概述与区别
- 车载软件架构——AUTOSAR的江湖夜雨十年灯
- antlr4读书笔记
- 为什么 Android 必须在主线程更新 UI ?
- 2021年中国床垫市场规模及重点企业对比分析:喜临门vs梦百合[图]
- Xmind专业版使用方法以及使用教程
- 初中生写作杂志初中生写作杂志社初中生写作编辑部2022年第6期目录
- Code::blocks的安装以及使用方法
- 每个Java类都有的toString方法
- js实现随机数字生成器代码