Created
September 2, 2016 04:46
-
-
Save sks147/95b4e0b0e9b55edfd2d6071079928ece to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
using namespace std; | |
int main(){ | |
string s; | |
cin>>s; | |
string s1; | |
s1=s; | |
for(int i=20;i<24;i++){ | |
s1[i]='0'; | |
} | |
unsigned int sum=0; | |
for(int i=0;i<40;i+=4){ | |
int a=0,b; | |
b=(int)s1[i]-48; | |
if(b<=9){ | |
a+=b; | |
a=a<<4; | |
} | |
else{ | |
b=(int)s1[i]-87; | |
a+=b; | |
a=a<<4; | |
} | |
b=(int)s1[i+1]-48; | |
if(b<=9){ | |
a+=b; | |
a=a<<4; | |
} | |
else{ | |
b=(int)s1[i+1]-87; | |
a+=b; | |
a=a<<4; | |
} | |
b=(int)s1[i+2]-48; | |
if(b<=9){ | |
a+=b; | |
a=a<<4; | |
} | |
else{ | |
b=(int)s1[i+2]-87; | |
a+=b; | |
a=a<<4; | |
} | |
b=(int)s1[i+3]-48; | |
if(b<=9){ | |
a+=b; | |
} | |
else{ | |
b=(int)s1[i+3]-87; | |
a+=b; | |
} | |
sum+=a; | |
if(sum>=65536){ | |
sum-=65536; | |
sum+=1; | |
} | |
} | |
sum=~sum; | |
string ans=""; | |
for(int i=0;i<4;i++){ | |
int a=sum%16; | |
if(a<10){ | |
char c=(char)(a+48); | |
ans=c+ans; | |
sum/=16; | |
} | |
else{ | |
char c=(char)(a+87); | |
ans=c+ans; | |
sum/=16; | |
} | |
} | |
cout<<ans<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment