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 ...
随机推荐
- 在junit格式的结果信息中只包含错误信息的修改方法
文件名称:suiteJunit.vm 文件路径:src\fitnesse\resources\templates 添加如下黑体部分内容: <?xml version="1.0" ...
- now code——小a和黄金街道(欧拉函数和快速幂模板)
小a和小b来到了一条布满了黄金的街道上.它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来决定最后得到的黄金的数量.游戏规则是这样的:假设道路长度为米(左端点 ...
- Codeforces482B【线段树构造】
题意: 有M个限制,每个限制有l,r,q,表示从a[l]~a[r]取且后的数一定为q,问是否有满足的数列. 思路: 看到大牛说是线段树,线段树对于区间操作,印象中乘啊,+啊,-啊都不错,但是并没有就是 ...
- js函数和变量的执行顺序【易错】
js函数和变量的声明与执行顺序 一.函数执行顺序 1.正常顺序 function f(){ alert(2); } f(); //alert 2 所有浏览器都能测试通过. 2.倒序调用 f(); // ...
- 转 在shell脚本中使用expect实现scp传输问题
1.安装expect expect用于shell脚本中自动交互,其是基于tcl编程语言的工具.所以安装expect首先安装tcl.本文中使用的是expect5.45和tcl8.6.6. 安装tcl [ ...
- 关于如何在其他包中写controller和简单介绍@SpringBootApplication
本文参考博客:https://blog.csdn.net/u013473691/article/details/52353923 关于@Configuration和@Bean参考博客:https:// ...
- python_12(并发编程)
第1章 进程 1.1 队列Queue 1.2 Queue方法 1.2.1 q.get([block [,timeout]]) 1.2.2 q.get_nowait() 1.2.3 q.put(item ...
- Solr查询中涉及到的Cache使用及相关的实现【转】
转自:http://www.cnblogs.com/phinecos/archive/2012/05/24/2517018.html 本文将介绍Solr查询中涉及到的Cache使用及相关的实现.Sol ...
- 《高性能MySQL》读书笔记之创建高性能的索引
索引是存储引擎用于快速找到记录的一种数据结构.索引优化是对查询性能优化的最有效手段.索引能够轻易将查询性能提高几个数量级.创建一个最优的索引经常需要重写查询.5.1 索引基础 在MySQL中,存储引擎 ...
- 解决java.lang.NoClassDefFoundError: javax/xml/rpc/service错误的方法
最近在做WebService项目,本地测试没有问题,打算部署到服务器上,但是部署后,访问时出现了如下图1的错误: 图1 图1报的是没有找到定义的类的错误.刷新页面有又出现了另外“新”的错误: 图2 根 ...