Combination Lock (UVA 13049) by beet1333
Contest: 3738    RunID: 20173574    Status: Wrong answer    Date: Sat Oct 14 13:48:16 JST 2017


#include<bits/stdc++.h>

using namespace std;

struct BeetAizu
{
  BeetAizu()
  {

  }

  void run()
  {
    int N;
    string A, B;
    cin >> N >> A >> B;
    int ret = 0;
    for(int i = 0; i < A.size(); i++) {
      int u = A[i] - '0';
      int v = B[i] - '0';
      ret += min(abs(u - v), 9 - abs(u - v));
    }
    cout << ret << endl;
  }
};

int main()
{
  BeetAizu beet;
  int T;
  cin >> T;
  for(int i = 1; i <= T; i++) {
    cout << "Case " << i << ": ";
    beet.run();
  }
}