Combination Lock (UVA 13049) by aizu_f
Contest: 3738    RunID: 20173718    Status: Wrong answer    Date: Sat Oct 14 14:15:14 JST 2017


#include <bits/stdc++.h>

using namespace std;

int solve(string init, string target, int n){
	int steps = 0;
	for(int i = 0; i < n; ++i){
		int val = target[i] - init[i];
		if(val > 0) steps += val;
		else steps += val + 10;
	}
	return steps;
}

int main(){
	int t;
	cin >> t;
	while(t--){
		int i = 1;
		int n;
		string init, target;
		cin >> n >> init >> target;
		cout << "Case " << i++ << ": " << solve(init, target, n) << endl;
	}
	return 0;
}