Codeforces Combination Lock
来源:互联网 发布:淘宝网卫裤 编辑:程序博客网 时间:2024/05/22 06:17
import java.util.Scanner;public class CombinationLock {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();char[] ch1 = scanner.next().toCharArray();char[] ch2 = scanner.next().toCharArray();int count = 0;for(int i = 0; i < n; i++) {int c1 = ch1[i] - '0';int c2 = ch2[i] - '0';if(c1 >= c2) {count += Math.min(9 - c1 + 1 + c2, c1 - c2);} else {count += Math.min(9 - c2 + 1 + c1, c2 - c1);}}System.out.println(count);}}
阅读全文
0 0
- Codeforces Combination Lock
- codeforces A. Combination Lock 贪心
- CodeForces 540A Combination Lock
- CodeForces 540A Combination Lock
- CodeForces 540A Combination Lock
- CodeForces 540A Combination Lock
- CodeForces—301A—Combination Lock
- Combination Lock
- Combination Lock
- contest: Codeforces Round #301 (Div. 2), problem: (A) Combination Lock
- codeforces——540A——Combination Lock
- fjnu 1501 Combination Lock
- 1501 Combination Lock
- poj 2304 Combination Lock
- 10550 - Combination Lock
- UVa 10550 - Combination Lock
- POJ2304 Combination Lock
- hust 1051 - Combination Lock
- Web基础之Cookie对象与Session对象(一)
- 【大数据部落】r语言多均线量化策略回测
- 序列化protobuf
- CSDN博客不能正常发布的问题
- sort-排序
- Codeforces Combination Lock
- 51nod 1110 距离之和最小 V3
- SQL Server添加Delete操作回滚日志
- 来听大师讲设计(下)
- Redis设计
- Python中的repr()函数
- 链表——带环问题
- 关于使用PDO连接数据库的一些基本操作
- 【大数据部落】如何使用rjags R2jags来建立贝叶斯模型