The first programming competition of Jiangxi University of Finance and Economics D

Link: https://www.nowcoder.com/acm/contest/115/D
Source: Niuke.com

Topic description

The thing, is this.
There is such a day at noon on a weekend.
I just threw my clothes into the washing machine, and sat next to me in a daze with a small bench.
Then I suddenly thought that I would be so bored and just play Onmyoji, so I took out my mobile phone from my cloak hat and logged into Onmyoji.
Looking at the new SSR shikigami written in the update announcement, I sighed: It would be great if I could have Ichimoku. I
glanced at my handsome boy, Gugu, when I was about to have trouble with my liver, I found the courtyard in the courtyard. The questionnaire in the string of lanterns was surrounded by butterflies, so I clicked in and filled out a wave. At the end, I wrote my wish at the time: I want to be connected at a glance.
Then I was rewarded with a talisman, and I drew it easily. I thought it was an R card again, but the phone vibrated.
Hold the grass! ! ! At a glance! ! ! !
At that time, I stood up excitedly and gave it a hard look, then laughed and took screenshots.
---------------------------------------------------------------------------------------
The full name of SSR is superior super rare. Generally the highest rarity level in card games.
 
The question is to give three characters and find the number of times it takes to upgrade to SSR.
The minimum is AAA and the maximum is SSR;
To upgrade from SSQ to SSR, you need to upgrade once.
Upgrading from SRR to SSR requires 19 upgrades.

Enter description:

Enter an integer T (representing the number of samples) in the first line, 
followed by T groups of samples
, one line for each sample, including three consecutive uppercase letters (A - S)

Output description:

One line per sample output 
the number of times it takes to upgrade to SSR
Example 1

enter

3
SSR
SRR
AAA

output

0
19
6857

Remark:

The process of upgrading SRR to SSR: 
SRR -> SRS -> SSA -> SSB -> SSC -> ……->SSR There are 19 times

without this remark, I can't understand why it is 19
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 int StringToInt(const string& str){
 5     int length = str.length();
 6     int sum = 0;
 7     for(int i = 0; i < length; i++){
 8         int temp = str[i] - 'A';
 9         sum = 19*sum + temp + 1;
10      }
11     return sum;
12 
13 }
14 int main(){
15     int t;
16     cin>>t;
17     while(t--){
18         string s;
19         cin>>s;
20         cout<<StringToInt("SSR")-StringToInt(s)<<endl;
21     }
22     return 0;
23 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324608976&siteId=291194637