看着前面咕咕咕的国庆集训 难受

十月十日要萌一天哇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的更多相关文章

  1. 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 ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. T^TOJ - 1251 - 。◕‿◕。TMD - 欧拉函数 - 质因数分解

    http://www.fjutacm.com/Problem.jsp?pid=1251 想了很久,一开始居然还直接枚举因子d,计算重复了. 首先你要找与n的最大公因子大于m的x的个数. \[\sum\ ...

  2. win7 mongod不是内部命令

    1.下载MongoDB 1.1 MongoDB下载 1.2 选择Server下面的 Community 2.安装MongoDB 2.1 注意事项:一直下一步就行了,但是遇到下面这个界面,注意一定要去掉 ...

  3. apache2.4.35 403 forbidden 解决办法

  4. Math对象产生随机数一个小应用

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. LightOJ 1029 【最小生成树】

    思路: 利用克鲁斯卡尔算法,最小生成树把边从小到大排序,然后Union: 最大生成树就是把边从大到小排序,然后Union: #include<bits/stdc++.h> using na ...

  6. jq weui 滚动加载的坑

    1.一般情况下使用官网给个demo就可以了,如下: var loading = false; //状态标记 $(document.body).infinite().on("infinite& ...

  7. 浅谈Nginx服务器的内部核心架构设计

    前言 Nginx 是一个 免费的 , 开源的 , 高性能 的 HTTP 服务器和 反向代理 ,以及 IMAP / POP3代理服务器. Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消 ...

  8. [題解](最小生成樹/LCA)luogu_P1967貨車運輸

    一道好題不出所料又抄的題解 1.首先對於這張圖肯定要考慮走哪些邊不走哪些邊,發現我們想要的肯定那些邊權最大的邊,所以想到最大生成樹 這樣能保證選到盡量大的邊 2.跑完最大生成樹后每兩點之間就有唯一路徑 ...

  9. 未知宽高div水平垂直居中的3种方法

    方法一 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  10. [POI2011]Plot

    https://szkopul.edu.pl/problemset/problem/mzrTn1kzVBOAwVYn55LUeAai/site/?key=statement 既卡常又卡精度...真的A ...