1426 - Password
Time Limit : 1 Second
Memory Limit : 128 MB
Gaewah loves play WenQuXing(文曲星) very much, especially his NC2600c.
One day, he use the PEEK functions of GVBASIC in NC2600c, found the system password(7 chars in total) in NC2600c was store as 7 bytes in the memory of NC2600c, but this 7 bytes was not directly real password, it's the result after calculation, and Gaewah found the way to get it:
Assume c1, c2, c3, c4, c5, c6, c7 is the ASCII of 7 chars of real password, and g1, g2, g3, g4, g5, g6, g7 is 7 bytes store in the memory
g1 = (c6 + c7 + c1) mod 256
g2 = (c7 + c1 + c2) mod 256
g3 = (c1 + c2 + c3) mod 256
g4 = (c2 + c3 + c4) mod 256
g5 = (c3 + c4 + c5) mod 256
g6 = (c4 + c5 + c6) mod 256
g7 = (c5 + c6 + c7) mod 256
Now Gaewah needs you write a program to help him verify whether the password is match the password store in the memory.
First line is T means T test cases in total.
Each test case has 2 lines.
The first line is 7 numbers g1, g2, g3, g4, g5, g6, g7 (0<=gi<256).
The second line is a password string contains exactly 7 chars (only contain letters and digits).
Print "Case #X:" (X is the case number) at the first line of each test case.
Next line is "Yes" if password string matches the code store in memory, or "No" if not. (Without quotation marks).
- sample input
2 46 42 38 41 44 47 50 abcdefg 46 42 38 41 44 47 50 ABCDEFG
- sample output
Case #1: Yes Case #2: No