2013蓝桥杯翻硬币
来源:互联网 发布:咪咕刷枪软件 编辑:程序博客网 时间:2024/06/06 15:47
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
char a[2000],b[2000];
int hash[2000],i;
int main()
{
scanf("%s%s",a,b);
int len = strlen(a);
for(i = 0; i<len; i++)
if(a[i] == b[i])
hash[i] = 0;
else
hash[i] = 1;
int ans = 0,flag = -1;
for(i = 0; i<len; i++)
{
if(hash[i])
{
if(flag == -1)
flag = i;
else
{
ans+=i-flag;
flag = -1;
}
}
}
printf("%d\n",ans);
return 0;
}
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
char a[2000],b[2000];
int hash[2000],i;
int main()
{
scanf("%s%s",a,b);
int len = strlen(a);
for(i = 0; i<len; i++)
if(a[i] == b[i])
hash[i] = 0;
else
hash[i] = 1;
int ans = 0,flag = -1;
for(i = 0; i<len; i++)
{
if(hash[i])
{
if(flag == -1)
flag = i;
else
{
ans+=i-flag;
flag = -1;
}
}
}
printf("%d\n",ans);
return 0;
}
0 0
- 2013蓝桥杯翻硬币
- 蓝桥杯翻硬币
- 蓝桥杯翻硬币
- 2013 翻硬币
- 2013 硬币方案
- 硬币
- 硬币
- 硬币
- 硬币
- 2013蓝桥杯 【初赛试题】 翻硬币
- 2013蓝桥杯【模拟赛】硬币方案
- 2013蓝桥杯预赛之翻硬币
- 蓝桥杯--2013--翻硬币(贪心)
- 2013蓝桥杯 【初赛试题】 翻硬币
- 硬币称重
- 翻硬币
- 找硬币
- 硬币人生
- 【找规律】HDOJ Rikka with Chess 5630
- jqgrid实现行拖拽功能
- 移动浏览器点击事件的问题
- 第一堂java课
- Android------<mainfest>标签详解
- 2013蓝桥杯翻硬币
- Hbase相关概念,配置总结
- 逻辑斯蒂回归2 -- 最大熵模型概念
- cmstop架构分析
- UITableViewCell相关
- js deep copy 解析json
- swift基础- 泛型(一)
- 自定义view中特殊问题编程思路
- IELTS