codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

50B.md (931B)


      1 Source: https://codeforces.com/problemset/problem/50/B
      2 
      3 B. Choosing Symbol Pairs
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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
     22 
     23 1. 1 ≤ *i*, *j* ≤ *N*
     24 
     25 2. *S*[*i*] = *S*[*j*], that is the *i*-th symbol of string *S* is equal to the *j*-th.
     26 
     27 Input
     28 
     29 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.
     30 
     31 Output
     32 
     33 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.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 great10
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 7
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 aaaaaaaaaa
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 100
     59 ```