Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void destobin(int n)
- {
- string str="";
- while(n)
- {
- long long digit =n%2;
- str +=(digit+'0');
- n=n/2;
- }
- string s=str;
- //cout<<str<<endl;
- reverse(str.begin(),str.end());
- //cout<<str<<endl;
- if(str==s)
- cout<<"YES"<<endl;
- else
- cout<<"NO"<<endl;
- return;
- }
- int main()
- {
- string str;
- char c;
- long long int cont=0,n,m;
- cin>>n;
- while(n--)
- {
- cont=0;
- while(cin>>str)
- {
- if(str=="one")
- {
- m=1;
- cont+=1;
- }
- else if(str=="two")
- {
- cont+=2;
- m=2;
- }
- else if(str=="three")
- {
- cont+=3;
- m=3;
- }
- else if(str=="four")
- {
- cont+=4;
- m=4;
- }
- else if(str=="five")
- {
- m=5;
- cont+=5;
- }
- else if(str=="six")
- {
- m=6;
- cont+=6;
- }
- else if(str=="seven")
- {
- m=7;
- cont+=7;
- }
- else if(str=="eight")
- {
- m=8;
- cont+=8;
- }
- else if(str=="nine")
- {
- m=9;
- cont+=9;
- }
- else if(str=="ten")
- {
- m=10;
- cont+=10;
- }
- else if(str=="eleven")
- {
- m=11;
- cont+=11;
- }
- else if(str=="twelve")
- { m=12;
- cont+=12;
- }
- else if(str=="thirteen")
- {
- m=13;
- cont+=13;
- }
- else if(str=="fourteen")
- {
- m=14;
- cont+=14;
- }
- else if(str=="fifteen")
- {
- m=15;
- cont+=15;
- }
- else if(str=="sixteen")
- {
- m=16;
- cont+=16;
- }
- else if(str=="seventeen")
- {
- m=17;
- cont+=17;
- }
- else if(str=="eighteen")
- {
- m=18;
- cont+=18;
- }
- else if(str=="nineteen")
- {
- m=19;
- cont+=19;
- }
- else if(str=="twenty")
- {
- m=20;
- cont+=20;
- }
- else if(str=="thirty")
- {
- m=30;
- cont+=30;
- }
- else if(str=="forty")
- {
- m=40;
- cont+=40;
- }
- else if(str=="fifty")
- {
- m=50;
- cont+=50;
- }
- else if(str=="sixty")
- {
- m=60;
- cont+=60;
- }
- else if(str=="seventy")
- {
- m=70;
- cont+=70;
- }
- else if(str=="eighty")
- {
- m=80;
- cont+=80;
- }
- else if(str=="ninety")
- {
- m=90;
- cont+=90;
- }
- else if(str=="hundred")
- {
- int n=m;
- m*=100;
- cont+=m-n;
- }
- else if(str=="thousand")
- {
- int n=m;
- m*=1000;
- cont+=m-n;
- }
- scanf("%c",&c);
- if(c=='\n')break;
- if(c==' ')continue;
- }
- //cout<<cont<<endl;
- destobin(cont);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement