1
//
G Accepted 0 196 409 C++
2 #include < iostream >
3 #include < algorithm >
4
5 using namespace std ;
6
7 char line[ 500 ] ;
8
9 int main()
10 {
11 while ( gets(line) )
12 {
13 if ( 0 == strcmp( line, " # " ) ) break ;
14
15 int out = 0 ;
16 int len = strlen( line ) ;
17
18 for ( int i = 0 ; i < len; i ++ )
19 {
20 if ( ' ' == line[i] )
21 out += (i + 1 ) * 0 ;
22 else
23 out += (i + 1 ) * (line[i] - ' A ' + 1 ) ;
24 }
25
26 printf( " %d\n " , out ) ;
27 }
28
29 return 0 ;
30 }
2 #include < iostream >
3 #include < algorithm >
4
5 using namespace std ;
6
7 char line[ 500 ] ;
8
9 int main()
10 {
11 while ( gets(line) )
12 {
13 if ( 0 == strcmp( line, " # " ) ) break ;
14
15 int out = 0 ;
16 int len = strlen( line ) ;
17
18 for ( int i = 0 ; i < len; i ++ )
19 {
20 if ( ' ' == line[i] )
21 out += (i + 1 ) * 0 ;
22 else
23 out += (i + 1 ) * (line[i] - ' A ' + 1 ) ;
24 }
25
26 printf( " %d\n " , out ) ;
27 }
28
29 return 0 ;
30 }