首页 > 其他分享 >baidu

baidu

时间:2023-04-21 22:25:16浏览次数:30  
标签:baidu std ch int cin ans include

冰雪大冒险

#include <bits/stdc++.h>

#define KV(x) #x << " " << x

signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);

  int n, m;
  std::cin >> n >> m;
  int sx, sy;
  std::cin >> sx >> sy;
  int k;
  std::cin >> k;
  std::vector<std::vector<int>> a(n + 1, std::vector<int>(m + 1));
  for (int i = 0; i < k; i++) {
    int x, y;
    std::cin >> x >> y;
    a[x][y] = 1;
  }

  std::string s;
  std::cin >> s;

  auto trans = [&](char ch) -> std::array<int, 2> {
    if (ch == 'D') return std::array<int, 2>{1, 0};
    else if (ch == 'L') return std::array<int, 2>{0, -1};
    else if (ch == 'R') return std::array<int, 2>{0, 1};
    else return std::array<int, 2>{-1, 0};
  };

  for (int i = 0; i < static_cast<int>(s.size()); i++) {
    std::array<int, 2> now = trans(s[i]);
    int xx = sx + now[0], yy = sy + now[1];
    while(xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == 0) {
      sx = xx, sy = yy;
      // std::cerr << KV(sx) << " " << KV(sy) << "\n";
      xx += now[0], yy += now[1];
    }
  }

  std::cout << sx << " " << sy << "\n";
}

房间打扫

#include <bits/stdc++.h>

#define KV(x) #x << " " << x

signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);

  int Max = 0;
  std::map<std::string, int> cnt;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    cnt[s]++;
    Max = std::max(cnt[s], Max);
  }

  std::cout << Max << "\n";
}

数字统计

#include <bits/stdc++.h>

#define KV(x) #x << " " << x

signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  std::cin >> n;

  int ans = 0;

  auto trans = [&](int x) -> bool {
    std::string now = std::to_string(x);
    std::reverse(now.begin(), now.end());
    int y = stoi(now);
    return x % y == 0;
  };

  for (int i = 1; i <= n; i++) {
    ans += trans(i);
  }
  std::cout << ans << "\n";
}

函数的幂

#include <bits/stdc++.h>

#define KV(x) #x << " " << x

signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);
  int a, b, C, D;
  std::cin >> a >> b >> C >> D;
  int ans = 0;
  std::function<int(int, int)> f = [&](int x, int y) -> int {
    if (x == 1) return (1ll * C * y % 10 + D % 10) % 10;
    else {
      return f(x - 1, f(x - 1, y));
    }
  };

  std::cout << f(a, b) << "\n";
}

项链

#include <bits/stdc++.h>

#define KV(x) #x << " " << x

signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  std::sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = n - 1; i >= (n + 1) / 2; i--) ans += a[i];
  for (int i = 0; i < n / 2; i++) ans -= a[i];
  ans <<= 1;
  std::cout << ans << "\n";
}

污渍

#include <bits/stdc++.h>

#define KV(x) #x << " " << x
#define int long long
signed main() {
  std::cin.tie(nullptr)->sync_with_stdio(false);
  std::vector<std::array<int, 3>> p(2);
  long long ans = 0;
  for (int i = 0; i < 2; i++) {
    std::cin >> p[i][0] >> p[i][1] >> p[i][2];
    ans += 1ll * p[i][2] * p[i][2];
  }

  std::pair<int, int> A = std::make_pair(std::min(std::max(p[0][0], p[1][0]), std::min(p[0][0] + p[0][2], p[1][0] + p[1][2])), 
                                         std::max(std::min(p[0][1], p[1][1]), std::max(p[0][1] - p[0][2], p[1][1] - p[1][2])));
  std::pair<int, int> B = std::make_pair(std::min(p[1][0] + p[1][2], p[0][0] + p[0][2]), 
                                         std::max(p[1][1] - p[1][2], p[0][1] - p[0][2]));
  // std::cout << A.first << " " << A.second << "\n";
  // std::cout << B.first << " " << B.second << "\n";
  if (B.first >= A.first && B.second <= A.second)
    ans -= std::max(0ll, 1ll * (B.first - A.first) * (A.second - B.second));
  std::cout << ans << "\n";
}

剧场

#include <bits/stdc++.h>

signed main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<char>> g(n + 10, std::vector<char>(n + 10, '0'));
  int N = n * n;
  for (int tc = 0; tc < N; tc++) {
    for (int i = n; i; i--) {
      for (int j = n; j; j--) {
        if (j == 1) {
          if (g[i][j] == '0' && g[i - 1][n] == '1') {
            g[i][j] = '1';
            g[i - 1][n] = '0';
          }
        } else {
          if (g[i][j] == '0' && g[i][j - 1] == '1') {
            g[i][j] = '1';
            g[i][j - 1] = '0';
          }
        }
      }
    }
    char ch;
    std::cin >> ch;
    if (ch & 1)
      g[1][1] = '1';
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      int ok = 0;
      for (int j = 1; j <= n; j++) {
        if (g[i][j] == '1')
          ok |= 1;
      }
      ans += ok;
    }
    std::cout << ans << " \n"[tc == N - 1];
  }
}

标签:baidu,std,ch,int,cin,ans,include
From: https://www.cnblogs.com/Haven-/p/17341497.html

相关文章

  • 百度:baidu快捷方式
    https://www.baidu.com/ <html><head><metacharset=UTF-8"><title>百度一下,你就知道</title><scripttype="text/javascript"> window.location.href='https://www.baidu.com/';</script></head>......
  • Module not found: Error: Can't resolve 'axios' in 'D:\BaiduSyncdisk\vue-cli-pr
    Modulenotfound:Error:Can'tresolve'axios'in'D:\BaiduSyncdisk\vue-cli-project\dc_vue3\src\utils'  因:没有安装axios插件在运行项目的地方npminstall--saveaxios解决办法 npminstall--saveaxios......
  • 面向chatgpt翻译:与google,baidu做对比
    先说结论:chatgpt完胜You翻译一下:ThechatbothassomeamazingcapabilitiesthatareveryclosetotheoriginalchatgptbutitdidinheritopenaiwoknesstoointhesensethatanycontroversialtopicisheavilyleaningtoaleftlibtardmindsetHopetofixthat......
  • 2.translate baidu
    该条笔记由Elder在2023/3/2721:37:12推送(百度翻译开发)定义命令(package.json)"activationEvents":[ "onCommand:translate.helloWorld" ]设置contributes(package.......
  • Baidu Cloud Intelligence Summit
    2022.12.27智能计算的发展为人工智能推动实体经济数智化升级提供算力支撑,AI安全的兼程并进更是支撑我国科技自立自强、实现高质量发展的必经之路,百度智能云与中国电子技术......
  • Washbaidu:有了它再也不担心检索到一堆广告了
    相信大家都有过在搜索页面中浮沉的经历。比如点开了一堆网站也没找到答案,然后还要收拾烂摊子,关闭一个个标签页。或者,搜索页上充斥着太多广告、热榜等不相关信息,拉低了自己......
  • Vue中使用百度地图,使用插件Vue-Baidu-Map
    项目开发需要使用的地图,通过列表选择地方,在地图中显示对应的位置信息。这里使用百度地图一,获取应用AK1、进入百度地图开放平台:https://lbsyun.baidu.com/2、注册账号3......
  • Baidu权重怎么查询?如何查百度权重?
    SEO人都想了解网站在百度检索中的权重,但是网站在不同的SEO查询工具中的排名不一样,比如一个网站在爱站PC权重、站长PC权重、爱站移动权重、站长移动权重等中的排名都是不一样......
  • Debian ping: www.baidu.com: Temporary failure in name resolution域名解析出错
    可以通过ip连接ping通,但是通过域名ping就会提示DNS暂时解析失败尝试了各种解决办法一、resolv.conf这个文件在debian9的目录/etc/systemed/目录下但是按照网上的方法直......
  • BAIDU_AI开放平台_天空分割的测试
    一、基本情况目前网络服务多以Http方式直接传播数据信息。在本次调用中,首先是开通权限​​​​而后是鉴权publicstaticclassAccessToken......