codeforces-scrape

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

145A.md (1548B)


      1 Source: https://codeforces.com/problemset/problem/145/A
      2 
      3 A. Lucky Conversion
      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 Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
     22 
     23 Petya has two strings *a* and *b* of the same length *n*. The strings consist only of lucky digits. Petya can perform operations of two types:
     24 
     25 * replace any one digit from string *a* by its opposite (i.e., replace 4 by 7 and 7 by 4);
     26 * swap any pair of digits in string *a*.
     27 
     28 Petya is interested in the minimum number of operations that are needed to make string *a* equal to string *b*. Help him with the task.
     29 
     30 Input
     31 
     32 The first and the second line contains strings *a* and *b*, correspondingly. Strings *a* and *b* have equal lengths and contain only lucky digits. The strings are not empty, their length does not exceed 105.
     33 
     34 Output
     35 
     36 Print on the single line the single number — the minimum number of operations needed to convert string *a* into string *b*.
     37 
     38 Examples
     39 
     40 Input
     41 
     42 ```
     43 47  
     44 74
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 1
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 774  
     57 744
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 1
     64 ```
     65 
     66 Input
     67 
     68 ```
     69 777  
     70 444
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 3
     77 ```
     78 
     79 Note
     80 
     81 In the first sample it is enough simply to swap the first and the second digit.
     82 
     83 In the second sample we should replace the second digit with its opposite.
     84 
     85 In the third number we should replace all three digits with their opposites.