toj 2975 Encription

2975.   Encription
Time Limit: 1.0 Seconds    Memory Limit: 65536K
Total Runs: 233    Accepted Runs: 88



Now CUET has its own local Area Network and almost all PCs are connected with each other. Often teachers give them very hard program to solve in a minimum time.

Sometimes Its not possible by all to solve those problem. Ultimately they go in the wrong Computer Lab has a software to detect C/C++. It prevents copying C++ programs through Network. But student of CUET are very smart. To avoid the Detective software, first they encode the C/C++ program then they send it to the destination. They always use shifting method (only for 'a' to 'z' and 'A' to 'Z') for encode. That is, they shifts each character by n. I.e. if n = 1 they use 'b' for 'a', 'c' for 'b' and so on. If n = 2 then 'c' for 'a', 'd' for 'b' ... 'a' for 'y' and 'b' for 'z'. It is the same for uppercase letter.

But the n is not defined for encoding.

you are hired to develop a detective program to decode the original program. They only information available for you is that "Letter of highest frequency for a C/C++ program is 'i' ". that is each C/C++ program the letter 'i' is type maximum times. Please note it is case-insensitive when calculating the frequency.

Input

Input will be an encoded C/C++ program.

Output

Your have to print the original C/C++ program.

Sample Input

#jodmvef
   
     
       Nbjo() { Jou j; j =5; qsjoug("%e",j); } 
     

Sample Output

#include
   
     
       Main() { Int i; i =5; print("%d",i); } 
     

Problem Setter: M H Rasel.



Source: CUET Easy Contest
Submit   List    Runs   Forum   Statistics

#include  < iostream >
#include 
< string >
#include 
< map >
#define  MAX 3000
using   namespace  std;
map
< char , int > M;
string  str[MAX];
int  num;
int  main()
{
    
int  kk,len,i,j,maxtemp;
    
char  maxchar;
    kk
= 0 ;
    M.clear();
    maxtemp
=- 1 ;
    
while (getline(cin,str[kk], ' \n ' ))
    {
        len
= str[kk].length();
        
for (i = 0 ;i < len;i ++ )
        {
            
if ((str[kk][i] >= ' a ' && str[kk][i] <= ' z ' ) || (str[kk][i] >= ' A ' && str[kk][i] <= ' Z ' ))
            {
                
if (M[str[kk][i]] == 0 )
                {
                    M[str[kk][i]]
= 1 ;
                    
if (maxtemp < 1 )
                    {
                        maxtemp
= 1 ;
                        maxchar
= str[kk][i];
                    }
                }
                
else
                {
                    M[str[kk][i]]
++ ;
                    
if (maxtemp < M[str[kk][i]])
                    {
                        maxtemp
= M[str[kk][i]];
                        maxchar
= str[kk][i];
                    }
                }
            }
        }
        kk
++ ;
    }
    
int  n = ' i ' - maxchar;
    
if (n > 0 && n >= 26 )
        n
%= 26 ;
    
char  temp;
    
for (i = 0 ;i < kk;i ++ )
    {
        len
= str[i].length();
        
for (j = 0 ;j < len;j ++ )
        {
            
if ((str[i][j] >= ' a ' && str[i][j] <= ' z ' ))
            {
                
if (n > 0 )
                {
                    
for ( int  kkk = 0 ;kkk < n;kkk ++ )
                    {
                        str[i][j]
++ ;
                        
if (str[i][j] > ' z ' )
                            str[i][j]
= ' a ' ;
                    }
                }
                
else
                {
                    temp
= str[i][j] + n;
                    
if (temp < ' a ' )
                    temp
= temp - ' a ' + ' z ' + 1 ;
                    str[i][j]
= temp;
                }
                
            }
            
else   if (str[i][j] >= ' A ' && str[i][j] <= ' Z ' )
            {
                    temp
= str[i][j] + n;
                    
if (temp > ' Z ' )
                    {
                        temp
= temp - ' Z ' + ' A ' - 1 ;
                    }
                    
else   if (temp < ' A ' )
                        temp
= temp - ' A ' + ' Z ' + 1 ;
                    str[i][j]
= temp;
            }
        }
    }
    
for (i = 0 ;i < kk;i ++ )
    {
        cout
<< str[i] << endl;
    }
    
return   0 ;
}

你可能感兴趣的:(IO)