Jonatan Gezelius 6 vuotta sitten
vanhempi
commit
7a8741cb11
1 muutettua tiedostoa jossa 79 lisäystä ja 0 poistoa
  1. 79 0
      p10424/p10424.cpp

+ 79 - 0
p10424/p10424.cpp

@@ -0,0 +1,79 @@
+#include <algorithm>
+#include <array>
+#include <bitset>
+#include <climits>
+#include <cstring>
+#include <iostream>
+#include <iomanip>
+#include <list>
+#include <map>
+#include <set>
+#include <sstream>
+#include <stack>
+#include <string>
+#include <utility>
+#include <vector>
+#include <queue>
+
+using namespace std;
+
+#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
+#define repto(i, b) rep(i, 0, b)
+#define trav(it, v) for(typeof((v).begin()) it = (v).begin();   \
+                it != (v).end(); ++it)
+
+typedef unsigned int nat;
+
+const int imax = INT_MAX;
+const int umax = UINT_MAX;
+
+nat get_number(string str)
+{
+    nat sum = 0;
+    for(auto c : str)
+    {
+        if(!isalpha(c))
+            continue;
+        sum += toupper(c) - 64;
+    }
+    while(sum/10)
+    {
+        nat new_sum = 0;
+        while(sum/10)
+        {
+            new_sum += sum % 10;
+            sum /= 10;
+        }
+        new_sum += sum % 10;
+        sum = new_sum;
+    }
+    return sum;
+}
+
+bool solve(nat tc)
+{
+    string first, second;
+
+    getline(cin, first);
+    getline(cin, second);
+
+    if(!first.length())
+        return false;
+
+    nat first_num = get_number(first);
+    nat second_num = get_number(second);
+
+    cout << fixed << setprecision(2) << min(first_num, second_num)/(float)max(first_num, second_num)*100 << " %" << endl;
+
+    return true;
+}
+
+int main()
+{
+	//Set to 0 if you need to read the number of cases first
+	nat n = 1 << 30;
+	if(!n) cin >> n;
+	for(nat i = 1; i <= n && solve(i); ++i);
+
+	return 0;
+}