Saleh127

UVA 377

Nov 16th, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. ll number(string a)
  5. {
  6. ll ans=0;
  7. for(ll i=0;i<a.size();i++)
  8. {
  9. ans*=4;
  10. if(a[i]=='U')
  11. {
  12. ans++;
  13. }
  14. else if(a[i]=='C')
  15. {
  16. ans+=2;
  17. }
  18. else if(a[i]=='D')
  19. {
  20. ans+=3;
  21. }
  22. }
  23. return ans;
  24. }
  25.  
  26. int main()
  27. {
  28. ios_base::sync_with_stdio(0);
  29. cin.tie(0);cout.tie(0);
  30.  
  31. ll t,i;
  32. cin>>t;
  33.  
  34. string a;
  35. cout<<"COWCULATIONS OUTPUT"<<endl;
  36. while(t--)
  37. {
  38. ll n1,n2;
  39. cin>>a;
  40. n1=number(a);
  41. cin>>a;
  42. n2=number(a);
  43. for(i=0;i<3;i++)
  44. {
  45. char x;
  46. cin>>x;
  47. if(x=='A')
  48. {
  49. n2+=n1;
  50. }
  51. else if(x=='L')
  52. {
  53. n2*=4;
  54. }
  55. else if(x=='R')
  56. {
  57. n2/=4;
  58. }
  59. }
  60. cin>>a;
  61. n1=number(a);
  62. if(n1==n2) cout<<"YES"<<endl;
  63. else cout<<"NO"<<endl;
  64. }
  65. cout<<"END OF OUTPUT"<<endl;
  66.  
  67. return 0;
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment