前言

和扬子曰大佬和慕容宝宝大佬一组,我压力巨大,而且掌机,累死我了,敲了一个下午的代码,他们两个人因为比我巨就欺负我QwQ。
依旧被二中学军爆锤,我真的好菜,慕容宝宝或者是扬子曰大佬来掌机一定成绩比我好。

A

签到题,用gets直接读字符串,判末尾就好了。

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[1000005];
int main() {
    while (gets(s)) {
        int len = strlen(s);
        if (s[len - 1] == '.') s[len - 1] = '!';
        printf("%s\n", s);
    }
    return 0;
}

B

这道题目还是非常巧妙的,因为暴力要超时\(O(n^2)\),那么如果要不满足构成三角形的条件,那么如果不能构成三角形的话,必须满足\(a[i]+a[i+1]>=a[i+2]\),假设已经递增排序,那么很明显,斐波那契数列能够让不构成三角形最多,打表发现第56项就超过了数据范围,那么就60以内暴力,60以外直接输出yes

#include <cstdio>
#include <algorithm>
#define N 200005
#define ll long long
using namespace std;
ll a[N], t[N];
int n, q;
int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i ++) {
        scanf("%lld", &a[i]);
    }
    while (q --) {
        int l, r;
        scanf("%d%d", &l, &r);
        if (l > r) {
            printf("NO\n");
        }
        else if (r - l + 1 > 60) {
            printf("YES\n");
        }
        else {
            int tot = 0;
            for (int i = l; i <= r; i ++) {
                t[++ tot] = a[i];
            }
            sort(t + 1, t + 1 + tot);
            bool fg = 0;
            for (int i = 1; i <= tot - 2; i ++) {
                if (t[i] + t[i + 1] > t[i + 2]) {
                    printf("YES\n");
                    fg = 1;
                    break;
                }
            }
            if (!fg) printf("NO\n");
        }
    }
    return 0;
}

D

有多少个不同的数。

#include <cstdio>
#include <map>
using namespace std;
map<int,bool>vis;
int n;
int main() {
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i ++) {
        int x;
        scanf("%d", &x);
        if (!vis[x]) ans++;
        vis[x] = 1;
    }
    printf("%d\n", ans);
    return 0;
}

E

E题算是一道非常有思维含量的一道题目,我们首先打表发现所有的奇数都是无解。偶数会发现,\(i\)和\(i+n/2\)的两条边都是相等的,那么就将两个点合并在一起就发现了是一个欧拉回路的问题。
代码咕咕掉了,没有调对。

H

求有多少个数对满足\(a_i^{a_j}>a_j^{a_i}\)。
稍微打几个表,就会发现4之后的都满足底数小的大,那么特判之前的就可以了

#include <cstdio>
#include <map>
#include <algorithm>
#define N 100005
using namespace std;
struct data {
    int x, id;
    data() {
        x = id = 0;
    }
    bool operator <(const data &rhs) const {
        return x < rhs.x;
    }
}a[N];
int ans[N], b[N];
map<int,int>mp;
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &a[i].x);
        b[i] = a[i].x;
        a[i].id = i;
        mp[a[i].x] ++;
    }
    sort(a + 1, a + 1 + n);
    int tot = 0;
    for (int i = 1; i <= n; i ++) {
        if (a[i].x == 1) ans[a[i].id] = 0;
        else {
            if (a[i].x != a[i - 1].x) {
                tot += mp[a[i].x];
                ans[a[i].id] = n - tot;
            }
            else {
                ans[a[i].id] = ans[a[i - 1].id];
            }
        }
    }
    for (int i = 1; i <= n; i ++) {
        if (b[i] == 2) ans[i] -= mp[3] + mp[4];
        if (b[i] == 3) ans[i] += mp[2];
    }
    for (int i = 1; i <= n; i ++) {
        printf("%d ", ans[i]);
    }
    return 0;
}

I

求双射的可能性
只要求出了25组那么第26组也被确定了,而且要建立双向关系。

#include <cstdio>
#include <cstring>
#define N 1000005
using namespace std;
char s1[N], s2[N];
int d1[30], d2[30];
int tot;
int main() {
    scanf("%s%s", s1, s2);
    int len = strlen(s1);
    memset(d1, 0, sizeof(d1));
    memset(d2, 0, sizeof(d2));
    for (int i = 0; i < len; i ++) {
        int x1 = s1[i] - 'a' + 1, x2 = s2[i] - 'a' + 1;
        if (d1[x1] == 0 && d2[x2] == 0) {
            ++tot;
            d1[x1] = x2;
            d2[x2] = x1;
            continue;
        }
        if (d1[x1] != 0 && d1[x1] != x2) {
            printf("Impossible");
            return 0;
        }
        if (d2[x2] != 0 && d2[x2] != x1) {
            printf("Impossible");
            return 0;
        }
        d1[x1] = x2;
        d2[x2] = x1;
    }
    if (tot == 25) {
        int p1, p2;
        for (int i = 1; i <= 26; i ++) {
            if (d1[i] == 0) p1 = i;
            if (d2[i] == 0) p2 = i;
        }
        d1[p1] = p2;
        d2[p2] = p1;
    }
    for (int i = 1; i <= 26; i ++) {
        if (d1[i] != 0) {
            printf("%c->%c\n", i + 'a' - 1, d1[i] + 'a' - 1);
        }
    }
    return 0;
}

J

答案就是\(max(0,n-k\times t)\)。
ps.开long long。

#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
int main() {
    ll n, k, t;
    scanf("%lld%lld%lld", &n, &k, &t);
    printf("%lld\n", max(1ll * 0, n - k * t));
    return 0;
}

K

玄学精度误差,可证明海伦公式最小的误差在0.25之内,那么就在二分查找的时候稍微扩大范围就好了。

#include <cstdio>
#include <algorithm>
#include <cmath>
#define db double
using namespace std;
db s[4000005];
struct node {
    db x, y;
}a[255];
int n, q, tot;
db sqr(db x) {
    return x * x;
}
db dist(int i, int j) {
    return sqrt(sqr(a[i].x - a[j].x) + sqr(a[i].y - a[j].y));
}
int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i ++) {
        scanf("%lf%lf", &a[i].x, &a[i].y);
    }
    tot = 0;
    for (int i = 1; i <= n; i ++) {
        for (int j = i + 1; j <= n; j ++) {
            for (int k = j + 1; k <= n; k ++) {
                db a = dist(i, j), b = dist(j, k), c = dist(i, k);
                s[++ tot] = sqrt(fabs(a + b + c) / 2.0) * sqrt(fabs(a + b - c) / 2.0) * sqrt(fabs(a - b + c) / 2.0) * sqrt(fabs(-a + b + c)/ 2.0);
            }
        }
    }
    sort(s + 1, s + 1 + tot);
    while (q --) {
        db l, r;
        scanf("%lf%lf", &l, &r);
        int d1 = lower_bound(s + 1, s + 1 + tot, l - 0.25) - s;
        int d2 = upper_bound(s + 1, s + 1 + tot, r + 0.25) - s;
        printf("%d\n", d2 - d1);
    }
    return 0;
}

[2019/03/17#杭师大ACM]赛后总结(被吊锤记)的更多相关文章

  1. 杭电ACM题单

    杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...

  2. 杭电acm习题分类

    专注于C语言编程 C Programming Practice Problems (Programming Challenges) 杭电ACM题目分类 基础题:1000.1001.1004.1005. ...

  3. Sqlite && EF Code FIRST 终极解决方案 2019.5.17

    Sqlite && EF Code FIRST 终极解决方案 2019.5.17 包括根据模型自动生成数据库,初始化数据,模型改变时的自动数据迁移等 2019.12.25 更新 支持E ...

  4. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  5. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  6. 杭电ACM(1002) -- A + B Problem II 大数相加 -提交通过

    杭电ACM(1002)大数相加 A + B Problem II Problem DescriptionI have a very simple problem for you. Given two ...

  7. 杭电acm阶段之理工大版

    想參加全国软件设计大赛C/C++语言组的同学,假设前一篇<C和指针课后练习题总结>没看完的,请先看完而且依照上面的训练做完,然后做以下的训练. 传送门:http://blog.csdn.n ...

  8. [2019.03.25]Linux中的查找

    TMUX天下第一 全世界所有用CLI Linux的人都应该用TMUX,我爱它! ======================== 以下是正文 ======================== Linu ...

  9. 2019.03.03 - Linux搭建go语言交叉环境

    编译GO 1.6版本以上的需要依赖GO 1.4版本的二进制,并且需要把GOROOT_BOOTSTRAP的路径设置为1.4版本GO的根目录,这样它的bin目录就可以直接使用到1.4版本的GO 搭建go语 ...

随机推荐

  1. Luogu P1546 最短网络 Agri-Net

    其实这道题根本没必要写,但为了测试vector+堆优化的Prim试一发. 再次觉得Prim和Dijkstra很像,堆优化版本也差不多. 和Dijkstra一样,Prim也是在之前的dis点中选取一个最 ...

  2. Luogu P1341 无序字母对

    突然发现我现在很喜欢打图论题. 然而都是很easy的. 这道题很坑,用C++打了一遍莫名Too many or too few lines. 然后我打出了我的独门绝技Pascal.这可能是我最后一次用 ...

  3. retinex图像增强算法的研究

    图像增强方面我共研究了Retinex.暗通道去雾.ACE等算法.其实,它们都是共通的.甚至可以说,Retinex和暗通道去雾就是同一个算法的两个不同视角,而ACE算法又是将Retinex和灰度世界等白 ...

  4. Duplicate entry * for key *

    一.问题 插入数据时报错 Duplicate entry * for key * 二.分析 建表语句 CREATE TABLE `t_product_result_config` ( `id` var ...

  5. springboot整合curator实现分布式锁

    理论篇: Curator是Netflix开源的一套ZooKeeper客户端框架. Netflix在使用ZooKeeper的过程中发现ZooKeeper自带的客户端太底层, 应用方在使用的时候需要自己处 ...

  6. Map获取key值

    有两种方法 public static void test4(){ Map<String, Object> map = new HashMap<>(); map.put(&qu ...

  7. Github以及推广

    非常抱歉,我忘记在这个博客上发一遍了,之前是我同学代发,而我忘记把链接给发过来... Github: http://www.cnblogs.com/case1/p/5060015.html 推广: h ...

  8. iOS开发线程安全问题

    先来看一下代码: - (void)viewDidLoad { [super viewDidLoad]; self.testStr = @"String initial complete&qu ...

  9. [问题解决]基于注解配置dubbo遇到ConnectionLoss for /dubbo/xxx问题解决

    今天升级spring版本的时候,同时升级dubbo的版本,采用的是dubbo的基于注解的配置方法,采用curator作为dubbo的客户端, curator版本为4.1.0,启动之后,发现一直报错 C ...

  10. window.setTimeout

    https://developer.mozilla.org/zh-CN/docs/Web/API/Window/setTimeout