AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 商店
  • 应用
  • 文章
    • 题解
    • 分享
    • 问答
  • 吐槽
  • 登录/注册

2022河南萌新联赛第(四)场:郑州轻工业大学

作者: 作者的头像   史一帆 ,  2022-08-01 08:51:11 ,  所有人可见 ,  阅读 44


2


A.



B.



C.最大公因数

#include <iostream>
#include <cstring>
#include <algorithm>
#define INF 0x3f3f3f3f
#define lowbit(x) -x&x
using namespace std;
typedef long long LL;
const int N = 1e5 + 10, mo = 100000007;

int main(){
    int T;
    scanf("%d", &T);
    while (T -- ){
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        l = (l - 1) / x + 1, r = r / x;
        if (r - l >= 1)
            printf("%d %d\n", l * x, (l + 1) * x);
        else
            puts("-1");
    }
    return 0;
}

D.


E.


F.



G.迷宫

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define lowbit(x) -x&x
using namespace std;
typedef long long LL;
const int N = 2010, mo = 100000007;

int dist[N][N];
char g[N][N];
int n, m;
bool st[N][N];
int dx[] = {0, -1, 0, 1}, dy[] = {-1, 0, 1, 0};

struct node{
    int x, y;
};

int spfa(){
    memset(dist, 0x3f, sizeof dist);
    queue<node> q;
    q.push({0, 0});
    st[0][0] = true;
    dist[0][0] = 0;
    while (!q.empty()){
        auto t = q.front();
        q.pop();
        for (int i = 0; i < 4; i ++ ){
            int nx = t.x + dx[i];
            int ny = t.y + dy[i];
            int add;
            if (g[nx][ny] == '*') add = 0;
            else add = 1;
            if (g[nx][ny] == '#') continue;
            if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
            if (dist[nx][ny] > dist[t.x][t.y] + add){
                dist[nx][ny] = dist[t.x][t.y] + add;
                q.push({nx, ny});
            }
        }
    }
    if (dist[n-1][m-1] != 0x3f3f3f3f) return dist[n-1][m-1];
    else return -1;
}

int main(){
    cin >> n >> m;
    for (int i = 0; i < n; i ++ )
        cin >> g[i];
    cout << spfa() << endl;
    return 0;
}

H.


I.



J.



K.试稥

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define lowbit(x) -x&x
using namespace std;
typedef long long LL;
const int N = 1e5 + 10, mo = 100000007;

unordered_map<LL, int> st;
vector<int> ans;
int n;
LL x, a;

int main(){
    int T;
    scanf("%d", &T);
    while (T -- ){
        st.clear();
        ans.clear();
        bool flag = true;
        cin >> n >> x;
        for (int i = 1; i <= n; i ++ ){
            cin >> a;
            if (!st[a]) st[a] = i;
        }
        a = 1;
        while (x){
            if (x & 1){
                if (!st[a]) flag = false;
                else ans.push_back(st[a]);
            }
            a *= 2;
            x >>= 1;
        }
        if (!flag) cout << -1 << endl;
        else{
            cout << ans.size() << endl;
            sort(ans.begin(), ans.end());
            for (int i = 0; i < ans.size(); i ++ ){
                if (i == ans.size() - 1)
                    cout << ans[i] << endl;
                else
                    cout << ans[i] << ' ';
            }
        }
    }
    return 0;
}

L.


0 评论

你确定删除吗?
1024
x

© 2018-2022 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息