【Codeforces Round #301 (Div. 2) A】 Combination Lock
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
模拟水题
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
//no pain no gain
int a[N+10],b[N+10],n;
int get_ans(int x,int y){
int temp = x;
int ans = 0;
while (temp!=y){
ans++;
temp--;
if (temp<0) temp = 9;
}
int cnt = 0;
while (x!=y){
cnt++;
x++;
if (x>9) x = 0;
}
ans = min(ans,cnt);
return ans;
}
char s[N+10];
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "rt", stdin);
#endif
scanf("%d",&n);
scanf("%s",s+1);
for (int i = 1;i <= n;i++) a[i] = s[i]-'0';
scanf("%s",s+1);
for (int i = 1;i <= n;i++) b[i] = s[i]-'0';
int ans = 0;
for (int i = 1;i <= n;i++)
ans+=get_ans(a[i],b[i]);
printf("%d\n",ans);
return 0;
}
【Codeforces Round #301 (Div. 2) A】 Combination Lock的更多相关文章
- 【Codeforces Round #301 (Div. 2) E】Infinite Inversions
[链接] 我是链接,点我呀:) [题意] 给你一个无限长的序列1,2,3,4... 然后给你n个操作. 每个操作ai,bi; 表示调换位置为ai和位置为bi的数的位置. (ai,bi<=10^9 ...
- 【Codeforces Round #301 (Div. 2) D】 Bad Luck Island
[链接] 我是链接,点我呀:) [题意] 剪刀.石头.布各有r,s,p个生活在同一个村子里. 它们两两之间相遇的几率都相同(相遇后就会按照划拳的规则判断输赢,输的人就死掉了). 问你最后只剩下剪刀,只 ...
- 【Codeforces Round #301 (Div. 2) C】 Ice Cave
[链接] 我是链接,点我呀:) [题意] 给你一个n*m的地图. 每个地图为0的时候可以安全走过,且走过后变成1. (一定要离开之后才会变成1) 而为1的则走过之后会掉入下一层. 你一开始在初始位置( ...
- 【Codeforces Round #301 (Div. 2) B】 School Marks
[链接] 我是链接,点我呀:) [题意] 已知k门成绩. 总共有n门成绩. 让你构造剩下的n-k门成绩,使得这n门成绩的中位数>=y,并且这n门成绩的和要小于等于x. n为奇数 [题解] 首先判 ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
随机推荐
- SQL 自增列清零方法
SQL Identity自增列清零方法1.使用DBCC控制台命令: dbcc checkident(表名,RESEED,0) 2.truncate table 也可将当前标识值清零 但当有外键等约束时 ...
- jquery事件 【mousedown与mouseup ----keydown与keypress与keyup】focus--blur--orrer--pageX-pageY
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...
- centOS6.3(64bit)Hadoop的Eclipse开发环境搭建
操作系统centos6.3(64位) 一个namenode 两个datanode Hadoop版本号:hadoop-1.1.2 Eclipse版本号:eclipse-standard-kepler-S ...
- LinkedHashMap<String, Bitmap>(0, 0.75f, true) LinkedHashMap的加载因子和初始容量分配
今天上午在CSDN的论坛里看到有朋友提的问题如下: /** @param maxSize Maximum sum of the sizes of the Bitmaps in this cache * ...
- IIS7下设置AD单点登录
简介:IIS7下设置AD单点登录 1.选中网站,双击“身份验证”: 2.启用“Window身份验证”.禁用“匿名身份验证”.启用“基本身份验证”: 3.在“基本身份验证”上面点右键,选择“编辑”,输入 ...
- linux环境下禅道搭建
1.下载禅道安装包,根据操作系统的版本: 2.上传包到linux的opt目录中: 3.解压包: cd /opt tar xzvf 禅道包名称,如:tar xzvf ZenTaoPMS.8.1.3.zb ...
- shell项目-告警系统
告警系统 1. 告警系统需求分析 需求:使用shell定制各种个性化告警工具,但需要统一化管理.规范化管理. 思路:指定一个脚本包,包含主程序.子程序.配置文件.邮件引擎.输出日志等. 主程序:作为整 ...
- 阅读笔记—JSP
JSP页面概述 JSP(JavaServer Page)是一种动态页面技术,它在java web应用中主要实现表现逻辑.JSP页面是在HTML页面中嵌入JSP元素的动态Web页面,一般来说JSP页面中 ...
- 洛谷 P2105 K皇后
P2105 K皇后 题目描述 小Z最近捡到了一个棋盘,他想在棋盘上摆放K个皇后.他想知道在他摆完这K个皇后之后,棋盘上还有多少了格子是不会被攻击到的. (Ps:一个皇后会攻击到这个皇后所在的那一行,那 ...
- [React] Define defaultProps and PropTypes as static methods in class component
class Toggle extends Component { static propTypes = { defaultOn: PropTypes.bool, on: PropTypes.bool, ...