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 ...
随机推荐
- Ogre 整体框架入门
ogre 是面向对象的3d图形引擎. root 是引擎的一个界面类,包含很多快捷的调用其他类的接口. 在ogre中,广泛的使用了单件模式,同时最大的保证了你不需要自己管理资源,除了是你自己new的对象 ...
- Ruby编程实践
命令 常量大写 类名和模块名首字母大写,驼峰法,MyClass,Person 方法名小写,ruby中末尾添加符号特殊含义:destroyMethod!表示这个方法具有破坏性:isPrime?表示返回b ...
- php随机生成验证图片
为了防止用户利用机器人自动注册.登录.灌水,现在网站一般都采用了验证码技术,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验证码信息,输入表单 ...
- 记录下java的个人测试方法
IDEA,用 JUnitGenerator V2. 0 做单元测试.. 如果是 SpringBoot,测试类上面加注解 @RunWith(SpringJUnit4ClassRunner.class) ...
- C 语言实例 - 字符串翻转
C 语言实例 - 字符串翻转 C 语言实例 C 语言实例 使用递归来翻转字符串. 实例 - 字符串翻转 #include <stdio.h> void reverseSentence(); ...
- win10无法写入删改c盘文件的解决方法
前言 最近使用了win10系统,结果发现无法对c盘的文件进行写入删改,在网上到处搜集资料,终于找到了解决方法,这里总结一下. 首先,本文针对的是win10家庭版,家庭版默认是不提供组策略功能,而我们需 ...
- go系列(1)- linux下安装go环境
安装GO 打开安装包下载地址,查看linux下go的最新版本 https://golang.google.cn/dl/ 经查看go的最新版本为go1.11.4.linux-amd64.tar.gz 右 ...
- Centos5.11 使用yum源
由于我是用的系统是Centos 5.11以停止更新很多年,故此yum也不能用,找了很多方法,最终yum能稳定的运行在Centos5.11上,下面开始一一讲解步骤: 1:首先更新yum源 地址:http ...
- mysql count 中使用case when 带条件及去重
SELECT CASE (SELECT NOW() > '2019-02-12 16:48:00') WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END ...
- [题解](gcd/lcm)luogu_P1072_Hankson的趣味题(NOIP2009)
连续三次不开longlong导致wa!!! 不开longlong一时爽,一会提交火葬场!!! OI千万条,longlong第一条 乘法不longlong,提交两行泪 暴力luogu就能过了???打好暴 ...