zoukankan      html  css  js  c++  java
  • jQuery火箭图标返回顶部代码

    题目

    永远不要怀疑劳动人民的智慧!

    把快读里最后的return直接返回零的

    我已经不是第一次写错了!

    我要是再写错我就******

    主要是逆向思维,把从两个点往(1, 1)走想成从(1, 1)点往这两个点走就好了

    没有什么的

    #include <cstdio>
    #include <iostream>
    using namespace std;
    const int N = 25;
    int ax, ay, bx, by, ans[N][N], head, tail, x, y;
    int dx[12] = {-2, -2, -2, -2, -1, -1, 1, 1, 2, 2, 2, 2}, dy[12] = {-2, -1, 1, 2, -2, 2, -2, 2, -2, -1, 1, 2};
    bool vis[N][N];
    struct node{
        int x, y;
    }zhan[N << 2];
    int read() {
        int s = 0, w = 1;
        char ch = getchar();
        while(!isdigit(ch)) {if(ch == '-') w = -1;ch = getchar();}
        while(isdigit(ch)) {s = s * 10 + ch - '0';ch = getchar();}
        return s * w;
    }
    void bfs(int ax, int ay, int bx, int by) {
        zhan[1].x = 1;
        zhan[1].y = 1;
        tail = 1;
        ans[1][1] = 1;
        vis[1][1] = 1;
        while(head < tail) {
            head++;
            for(int i = 0; i < 12; i++) {
                x = zhan[head].x + dx[i], y = zhan[head].y + dy[i];
                if(x >= 1 && x <= 20 && y >= 1 && y <= 20 && !vis[x][y]) {
                    zhan[++tail].x = x;
                    zhan[tail].y = y;
                    ans[x][y] = ans[zhan[head].x][zhan[head].y] + 1;
                    vis[x][y] = 1;
                }
            }
        }
    }
    int main() {
        ax = read(), ay = read();
        bx = read(), by = read();
        bfs(ax, ay, bx, by);
        printf("%d
    %d
    ", ans[ax][ay] - 1, ans[bx][by] - 1);
        return 0;
    }

    谢谢收看,祝身体健康!

  • 相关阅读:
    PHP thinkPHP6.0 部署
    ch09 Sql导入语句
    自定义map 搜索
    MySql 语句
    自定义Mappter
    三袋米的故事
    WPF中实现文件夹对话框(OpenFileDialog in WPF)
    web通过Ajax与WCF交互
    项目管理之我见-程序员程序开发步骤
    存储过程
  • 原文地址:https://www.cnblogs.com/yanxiujie/p/11686690.html
Copyright © 2011-2022 走看看