MWC '15 #1 P5: Love Guru

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Hypnova is a love guru. He has a mathematical way to determine the compatibility of two people. His method is as follows:

  1. Take the names of the two people and perform the following process:
    • Take the value of each letter (a = 1, b = 2, c = 3, etc.) and put it to the power of its position in the name (starting from 1).
    • Sum these values together and mod the number by 10 into the range [1, 10]
  2. Add these two values together to get the compatibility out of 20.

Hypnova needs you to make a program that calculates two people's compatibility based on the criterion described above. The program should not be case sensitive.

Input Specification

Given names A and B, find their compatibility out of 20. The names are guaranteed to consist of only latin letters and L (1 \le L \le 10^6) letters in length.

Subtask 1 [10%]

1 \le L \le 6

Subtask 2 [20%]

1 \le L \le 20

Subtask 3 [70%]

1 \le L \le 10^6

Output Specification

A number in the range [2, 20].

Sample Input

Romeo
Juliet

Sample Output

15

Explanation for Sample Output

Romeo: 18^1 + 15^2 + 13^3 + 5^4 + 15^5 = 762\,440 \equiv 10 \pmod{10}
Juliet: 10^1 + 21^2 + 12^3 + 9^4 + 5^5 + 20^6 = 64\,011\,865 \equiv 5 \pmod{10}
Compatibility: 10 + 5 = 15


Comments


  • 5
    icicreampoph  commented on March 17, 2016, 11:56 p.m.

    Hypnova sensei, I'm lonely can you set me up? pls <3 <3


    • -5
      ramjet_engine  commented on March 19, 2016, 4:28 p.m.

      This comment is hidden due to too much negative feedback. Click here to view it.


      • 3
        Hypnova  commented on March 19, 2016, 5:52 p.m.

        Wrong Ryan!


        • -1
          ramjet_engine  commented on March 20, 2016, 11:46 a.m.

          So it's Ryan Jiang?


    • 1
      Hypnova  commented on March 18, 2016, 4:30 p.m.

      Me too


  • 1
    Jeffmagma  commented on March 16, 2016, 11:01 a.m.

    Isn't 10 mod 10 0?


    • 0
      aurpine  commented on March 16, 2016, 5:29 p.m. edited

      Yes, but the problem statement says:

      ...mod the number by 10 into the range [1,10]


  • 3
    odaniel  commented on March 14, 2016, 11:27 a.m.

    If both names have a compatibility of 1, the minimum output should be 2.


    • 0
      aurpine  commented on March 16, 2016, 5:27 p.m.

      Right. Problem statement updated.