题目链接:http://codeforces.com/problemset/problem/725/B
思路:注意第一个乘务员是从1开始,第二个从三开始,然后模拟下即可
下面给出AC代码:
1 #include<bits/stdc++.h>
2 using namespace std;
3 __int64 judge(char c) 4 { 5 if(c=='f') 6 return 1; 7 if(c=='e') 8 return 2; 9 if(c=='d') 10 return 3; 11 if(c=='a') 12 return 4; 13 if(c=='b') 14 return 5; 15 if(c=='c') 16 return 6; 17 } 18 int main() 19 { 20 __int64 n,m,k,l,sum; 21 char str[3]; 22 while(scanf("%I64d%s",&n,str)!=EOF) 23 { 24 k=n/4; 25 l=n%4; 26 if(l==1||l==2) 27 { 28 sum=(k*2+l)*6+(n-1); 29 } 30 else if(l==3) 31 { 32 sum=(k*2+1)*6+(n-1)-2; 33 } 34 else if(l==0) 35 { 36 k=k-1; 37 sum=(k*2+2)*6+(n-1)-2; 38 } 39 sum+=judge(str[0])-6; 40 printf("%I64d\n",sum); 41 } 42 return 0; 43 }