HDU 4357 String change 法冠军
2024-08-31 19:53:36
意甲冠军:
鉴于a串b串,问我们能否a变b串
办法:自选a的2快报,ascil+=1 然后交换位置,能够操作自如倍。
3个月3以上就能T^T
2法官将着眼于暴力
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 66;
char a[N], b[N];
bool check() {
int n = 60;
while(n -- > 0) {
swap(a[0], a[1]);
a[0] ++;
a[1] ++;
if(a[0] > 'z') a[0] = 'a';
if(a[1] > 'z') a[1] = 'a'; if(a[0] == b[0] && a[1] == b[1]) return true;
}
return false;
} int main() {
int T, cas = 0;
scanf("%d", &T);
while(T-- > 0) {
scanf("%s%s", a, b);
int n = strlen(a);
bool ok = 0;
if(n == 2) {
if(check()) ok = 1;
else ok = 0;
} else {
int s1 = 0, s2 = 0;
for(int i = 0; i < n; i ++) {
s1 += a[i] - 'a';
s2 += b[i] - 'a';
}
if((s1+s2)&1) ok = 0;
else ok = 1;
}
if(ok) printf("Case #%d: YES\n", ++cas);
else printf("Case #%d: NO\n", ++cas);
}
return 0;
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
最新文章
- 导出excel表格。
- IIS 301 跳转
- Nodejs Express 4.X 中文API 4--- Router篇
- PHP实现前台同步显示后台任务进度
- windows环境下mysql忘记密码如何重置
- Oracle错误代码案例总结及解决方案
- Android中的自定义属性的实现
- 无法为数据库 XXX 中的对象XXX 分配空间,因为 &#39;PRIMARY&#39; 文件组已满。请删除不需要的文件、删除文件组中的对象、将其他文件添加到文件组或为文件组中的现有文件启用自动增长,以便增加可用磁盘空间。
- Cent OS 修改网卡配置
- leetcode先刷_Unique Binary Search Trees II
- K:枚举的线程安全性及其序列化问题
- lintcode 链表求和
- VisualStudioCode中用dotnet命令创建多个ASP.NET Core 项目、类库、控制台程序,并添加应用间的引用
- Element-ui表格选中回显
- Exception in thread ";main"; java.lang.UnsupportedClassVersionError: org/apache/ma ven/cli/Maven
- HTTP1.0、HTTP1.1 和 HTTP2.0 的区别
- Eclipse中安装springmvc插件
- Jdbc连接Oracle12C集群环境
- 【Java并发编程】之十四:图文讲述同步的另一个重要功能:内存可见性
- 假如 GFW 遇上 ML
热门文章
- sublime text2 基本配置及结合Python 环境
- 微信小程序--成语猜猜看
- GCD 初步学习
- MapReduce&;#160;图解流程
- iOS开发Quzrtz2D:十一:图片截屏以及图片擦除
- 1. java.util.concurrent - Java 并发工具包
- 日期和时间的格式化定义(ISO C89)
- [RxJS] Flatten a higher order observable with concatAll in RxJS
- [RxJS] Split an RxJS observable with window
- js进阶正则表达式15验证身份证号(|符号的使用:var reg=/^\d{17}[\d|X]$|^\d{15}$/)(str的方法substr)