p10424.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <algorithm>
  2. #include <array>
  3. #include <bitset>
  4. #include <climits>
  5. #include <cstring>
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <list>
  9. #include <map>
  10. #include <set>
  11. #include <sstream>
  12. #include <stack>
  13. #include <string>
  14. #include <utility>
  15. #include <vector>
  16. #include <queue>
  17. using namespace std;
  18. #define rep(i, a, b) for(int i = (a); i < int(b); ++i)
  19. #define repto(i, b) rep(i, 0, b)
  20. #define trav(it, v) for(typeof((v).begin()) it = (v).begin(); \
  21. it != (v).end(); ++it)
  22. typedef unsigned int nat;
  23. const int imax = INT_MAX;
  24. const int umax = UINT_MAX;
  25. nat get_number(string str)
  26. {
  27. nat sum = 0;
  28. for(auto c : str)
  29. {
  30. if(!isalpha(c))
  31. continue;
  32. sum += toupper(c) - 64;
  33. }
  34. while(sum/10)
  35. {
  36. nat new_sum = 0;
  37. while(sum/10)
  38. {
  39. new_sum += sum % 10;
  40. sum /= 10;
  41. }
  42. new_sum += sum % 10;
  43. sum = new_sum;
  44. }
  45. return sum;
  46. }
  47. bool solve(nat tc)
  48. {
  49. string first, second;
  50. getline(cin, first);
  51. getline(cin, second);
  52. if(!first.length())
  53. return false;
  54. nat first_num = get_number(first);
  55. nat second_num = get_number(second);
  56. cout << fixed << setprecision(2) << min(first_num, second_num)/(float)max(first_num, second_num)*100 << " %" << endl;
  57. return true;
  58. }
  59. int main()
  60. {
  61. //Set to 0 if you need to read the number of cases first
  62. nat n = 1 << 30;
  63. if(!n) cin >> n;
  64. for(nat i = 1; i <= n && solve(i); ++i);
  65. return 0;
  66. }