Advertisement
deushiro

Untitled

Mar 8th, 2020
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7.  
  8. int main() {
  9.   string a, b;
  10.   cin >> a >> b;
  11.   double ans1 = 0;
  12.   double ans2 = 0;
  13.   reverse(a.begin(), a.end());
  14.   reverse(b.begin(), b.end());
  15.   for(int i = 0; i < a.size(); ++i){
  16.     double x = (a[i] - '0') * pow(16, i - 5);
  17.     cout << x << endl;
  18.     ans1 += x;
  19.   }
  20.   for(int i = 0; i < b.size(); ++i){
  21.     double y = 0;
  22.     if(b[i] == 'A')
  23.       y = 10;
  24.     else
  25.       y = 11;
  26.     double x = y * pow(16, i - 6);
  27.     ans2 += x;
  28.   }
  29.   cout << ans1 << " " << ans2 << endl;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement