Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.92 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. void destobin(int n)
  4. {
  5.  
  6.     string str="";
  7.     while(n)
  8.     {
  9.         long long digit =n%2;
  10.         str +=(digit+'0');
  11.         n=n/2;
  12.     }
  13.  
  14.     string s=str;
  15.     //cout<<str<<endl;
  16.  
  17.     reverse(str.begin(),str.end());
  18.      //cout<<str<<endl;
  19.     if(str==s)
  20.          cout<<"YES"<<endl;
  21.     else
  22.         cout<<"NO"<<endl;
  23.     return;
  24.  
  25. }
  26.  
  27.  
  28.  
  29. int main()
  30. {
  31.     string str;
  32.     char c;
  33.     long long int cont=0,n,m;
  34.     cin>>n;
  35.     while(n--)
  36.     {
  37.         cont=0;
  38.         while(cin>>str)
  39.         {
  40.  
  41.         if(str=="one")
  42.         {
  43.           m=1;
  44.           cont+=1;
  45.         }
  46.         else if(str=="two")
  47.             {
  48.                 cont+=2;
  49.                 m=2;
  50.             }
  51.         else if(str=="three")
  52.             {
  53.                 cont+=3;
  54.                 m=3;
  55.             }
  56.  
  57.         else if(str=="four")
  58.             {
  59.                 cont+=4;
  60.                 m=4;
  61.             }
  62.         else if(str=="five")
  63.             {
  64.                 m=5;
  65.                 cont+=5;
  66.             }
  67.         else if(str=="six")
  68.             {
  69.                 m=6;
  70.                 cont+=6;
  71.             }
  72.         else if(str=="seven")
  73.  
  74.             {
  75.                 m=7;
  76.                 cont+=7;
  77.             }
  78.         else if(str=="eight")
  79.             {
  80.                 m=8;
  81.                 cont+=8;
  82.             }
  83.         else if(str=="nine")
  84.             {
  85.                 m=9;
  86.                 cont+=9;
  87.             }
  88.         else if(str=="ten")
  89.             {
  90.                 m=10;
  91.                 cont+=10;
  92.             }
  93.         else if(str=="eleven")
  94.              {
  95.                  m=11;
  96.                  cont+=11;
  97.              }
  98.         else if(str=="twelve")
  99.             {    m=12;
  100.                 cont+=12;
  101.             }
  102.         else if(str=="thirteen")
  103.             {
  104.                 m=13;
  105.                 cont+=13;
  106.             }
  107.  
  108.         else if(str=="fourteen")
  109.             {
  110.                 m=14;
  111.                 cont+=14;
  112.             }
  113.         else if(str=="fifteen")
  114.             {
  115.                 m=15;
  116.                 cont+=15;
  117.             }
  118.         else if(str=="sixteen")
  119.             {
  120.                 m=16;
  121.                 cont+=16;
  122.             }
  123.         else if(str=="seventeen")
  124.             {
  125.                 m=17;
  126.                 cont+=17;
  127.             }
  128.         else if(str=="eighteen")
  129.             {
  130.                 m=18;
  131.                 cont+=18;
  132.             }
  133.         else if(str=="nineteen")
  134.             {
  135.                 m=19;
  136.                 cont+=19;
  137.             }
  138.  
  139.          else if(str=="twenty")
  140.             {
  141.                 m=20;
  142.                 cont+=20;
  143.             }
  144.         else if(str=="thirty")
  145.             {
  146.                 m=30;
  147.                 cont+=30;
  148.             }
  149.         else if(str=="forty")
  150.             {
  151.                 m=40;
  152.                 cont+=40;
  153.             }
  154.  
  155.         else if(str=="fifty")
  156.             {
  157.                 m=50;
  158.                 cont+=50;
  159.             }
  160.         else if(str=="sixty")
  161.             {
  162.                 m=60;
  163.                 cont+=60;
  164.             }
  165.         else if(str=="seventy")
  166.             {
  167.                 m=70;
  168.                 cont+=70;
  169.             }
  170.         else if(str=="eighty")
  171.             {
  172.                 m=80;
  173.                 cont+=80;
  174.             }
  175.         else if(str=="ninety")
  176.             {
  177.                 m=90;
  178.                 cont+=90;
  179.             }
  180.         else if(str=="hundred")
  181.             {
  182.                 int n=m;
  183.                 m*=100;
  184.                 cont+=m-n;
  185.             }
  186.         else if(str=="thousand")
  187.             {
  188.                 int n=m;
  189.                 m*=1000;
  190.                 cont+=m-n;
  191.             }
  192.  
  193.  
  194.         scanf("%c",&c);
  195.         if(c=='\n')break;
  196.         if(c==' ')continue;
  197.  
  198.     }
  199.     //cout<<cont<<endl;
  200.  
  201.     destobin(cont);
  202.  
  203.     }
  204.  
  205.     return 0;
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement