把密码锁调到目标位置,最少拨多少下。很水……
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cctype>
#define LL long long
using namespace std;
char s1[1005], s2[1005];
int main() {
int n; scanf ("%d", &n);
scanf ("%s %s", s1, s2);
int ans = 0;
for (int i = 0; i < n; i ++) {
if (s2[i] > s1[i]) {
ans += min (s2[i] - s1[i], s1[i] + 10 - s2[i]);
} else {
ans += min (s1[i] - s2[i], s2[i] + 10 - s1[i]);
}
}
printf ("%d\n", ans);
return 0;
}