Combination Lock (UVA 13049) by return_zukky
Contest: 3738    RunID: 20173575    Status: Presentation error    Date: Sat Oct 14 13:48:20 JST 2017


#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,o=0;
  cin>>n;
  while(n--){
    cout<<"Case "<<++o<<" :";
    int a,ans=0;
    string b,c;
    cin>>a>>b>>c;
    r(i,a){
      int x=b[i]-'0';
      int y=c[i]-'0';
      ans+=min(abs(x-y),abs(max(x,y)-10)+min(x,y));
    }
    cout<<ans<<endl;
  }
}