GYM 101604 || 20181010
看着前面咕咕咕的国庆集训 难受
十月十日要萌一天哇www
A.字符串
题意:给定一个字符串 问能否交换两个字符或者不交换字符,使其成为回文串
之前写的太丑 重写一遍加一堆 if 竟然过了w
思路:求出正序和倒叙有多少个不同的,根据不同的数量以及字符串长度(奇偶)判断。。
体验就是这种题要想好了再下笔。。(*下键盘
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn = ;
char str[maxn];
int idx[][];
int main()
{
scanf("%s", str);
int len = strlen(str);
int cnt = ;
for(int i = ; i < (len>>); i++)
{
if(cnt > ) break;
if(str[i] != str[len--i]) cnt++, idx[cnt-][] = str[i], idx[cnt-][] = str[len--i];
}
if(!cnt) printf("YES\n");
else if(cnt > ) printf("NO\n");
else if(cnt == && (len&) && (idx[][]==str[len>>] || idx[][]==str[len>>])) printf("YES\n");
else if(cnt == ) printf("NO\n");
else if((idx[][] == idx[][] && idx[][] == idx[][]) || (idx[][]==idx[][] && idx[][]==idx[][])) printf("YES\n");
else printf("NO\n");//
return ;
}
B.贪心(?)
题意:坐标系中,起始位置(1, 1) ,有n张卡片,可以按不同顺序执行,卡片上写t, x, y, 分为两种,t == 1是向右走x步再向左走y步, t == 2是向上走x步再向下走y步,到坐标轴就GG
思路:想一想可以发现(嗯我第一次就是因为没有想以为就是模拟wa了 zz难受)只要在横着和竖着移动的合能≥0,那么就可以有一种策略使它不能到坐标轴
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn = ;
int main()
{
int n;
scanf("%d", &n);
int x = , y = ;
bool ok = true;
for(int i = ; i < n; i++)
{
int t, xi, yi;
scanf("%d%d%d", &t, &xi, &yi);
if(t==){
x += xi;
x -= yi;
}
if(t==){
y += xi;
y -= yi;
}
}
if(x <= || y <= ) printf("NO\n");
else printf("YES\n(%d, %d)\n", x, y);
return ;
}
好困 留坑orz
好困 填坑orz
C.数字思维
题意:f(x) = x - x的每一位数的平方,如f(45) = 45 - 4*4 - 5*5
求n位数中函数值最大和最小的数,和它们的函数值
思路:对于最小值,一位数减的最多的一定是9 - 81,十位以上的话一定是0,因为10-1>0, 20-4>0, 30-9>0……,所以格式就是1000009
对于最大值,一定要9开头,因为900-81>800-64……,然后呢,40-16=24, 50-25=25, 60-36=24, 所以两位数的话要50能得到最大值,所以格式是9999999950
输出一下就可以了
zz错误。。过长的时候先计算后12位减的结果,后12位应该是999999999950而不是12个9……
#include <stack>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL pow10(int x)
{
LL ans = ;
for(int i = ; i < x; i++)
ans *= 10LL;
return ans;
}
int main()
{
int n;
scanf("%d", &n);
LL maxx, max_idx, minn, min_idx;
if(n==) {printf("1\n9\n0\n-72\n"); return ;}
if(n < )
{
max_idx = pow10(n)-;
min_idx = pow10(n-) + ;
maxx = max_idx, minn = min_idx;
for(int i = ; i < n-; i++) maxx -= ;
maxx -= ;
minn -= ;
printf("%lld\n%lld\n%lld\n%lld\n", max_idx, min_idx, maxx, minn);
return ;
}
for(int i = ; i < n-; i++) printf(""); printf("50\n");
printf(""); for(int i = ; i < n-; i++) printf(""); printf("9\n");
LL tmp = 999999999950LL;//啊啊啊这里最后是50
tmp = tmp - (LL)(*(n-)) - 25LL;
for(int i = ; i < n; i++) printf(""); printf("%lld\n", tmp);
for(int i = ; i < n-; i++) printf(""); printf("27\n");
return ;
}
/*
9999950
1000009
(max_idx)
(min_idx)
*/
GYM 101604 || 20181010的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- ASP.NET Core Web API + Angular 仿B站(三)后台配置 JWT 的基于 token 的验证
前言: 本系列文章主要为对所学 Angular 框架的一次微小的实践,对 b站页面作简单的模仿. 本系列文章主要参考资料: 微软文档: https://docs.microsoft.com/zh-cn ...
- Chrome开发者工具 debug 调试
Chrome 的开发者工具分为 8 个大模块,每个模块及其主要功能为: Element 标签页: 用于查看和编辑当前页面中的 HTML 和 CSS 元素. Network 标签页:用于查看 HTTP ...
- Rigging a Versatile Weapon Bone for 3ds Max
说明:先添加weapon到点的约束,位置,方向约束都调整好了后再建立点到手,hip的父子关系,注意这个顺序 加点的方法 点设置成box的方法: http://hewiki.heroengine.com ...
- Node.js 内置模块fs(文件系统)
fs模块的三个常用方法 1.fs.readFile() -- 读文件 2.fs.writeFile() -- 写文件 3.fa.stat() -- 查看文件信息 fs模块不同于其它模块的地方是它有异步 ...
- C语言带参宏定义和函数的区别
带参数的宏和函数很相似,但有本质上的区别:宏展开仅仅是字符串的替换,不会对表达式进行计算:宏在编译之前就被处理掉了,它没有机会参与编译,也不会占用内存.而函数是一段可以重复使用的代码,会被编译,会给它 ...
- spring boot 配置https 报这个错误:java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
找了接近半天的时间,原来是那么小的问题 server.ssl.key-store=test.jksserver.ssl.key-store-password=123456server.ssl.key- ...
- 【aspnetcore】模拟中间件处理请求的管道
几个核心对象: ApplicationBuilder 就是startup->Configure方法的第一个参数,请求(HttpContext) 就是由这个类来处理的 HttpContext 这个 ...
- libev 使用
观察器 IO ev_io_init (ev_io *, callback, int fd, int events) ev_io_set (ev_io *, int fd, int events) I/ ...
- GDB 格式化结构体输出
转载:http://blog.csdn.net/unix21/article/details/9991925 set print addressset print address on打开地址输出,当 ...
- 17999 Light-bot 模拟 + kmp求循环节
http://acm.scau.edu.cn:8000/uoj/mainMenu.html 17999 Light-bot 时间限制:1000MS 内存限制:65535K 提交次数:0 通过次数:0 ...