2019 ICPC Asia Yinchuan Regional

目录

  • Contest Info
  • Solutions
    • A. Girls Band Party
    • B. So Easy
    • D. Easy Problem
    • E. XOR Tree
    • F. Function!
    • G. Pot!!
    • H. Delivery Route
    • I. Base62
    • K. Largest Common Submatrix
    • N. Fibonacci Sequence

Contest Info



Practice Link

Solved A B C D E F G H I J K L M N
9/14 O O - O - O O O O - O - - O
  • O 在比赛中通过
  • ? 赛后通过
  • ! 尝试了但是失败了
  • - 没有尝试

Solutions


A. Girls Band Party

B. So Easy

题意:
给出一个\(n \cdot n\)的矩形,这个矩形\(a_{i, j}\)的初始值为\(0\),它每次能够选择一行或者一列加上\(1\),现在遮住某个位置的数,让你还原这个数。

思路:
考虑倒退操作,不考虑遮住的那个数,然后枚举每行,每列,每次选择行最小,列最小将整行整列减去即可还原出那个数。

代码:

view code

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int n, a[N][N];

int main() {
    while (scanf("%d", &n) != EOF) {
        int x = -1, y = -1;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                scanf("%d", &a[i][j]);
                if (a[i][j] == -1) {
                    x = i, y = j;
                    a[i][j] = 0;
                }
            }
        }
        for (int i = 1; i <= n; ++i) {
            int Min = 1e9;
            for (int j = 1; j <= n; ++j) {
                if (x == i && y == j) continue;
                Min = min(Min, a[i][j]);
            }
            for (int j = 1; j <= n; ++j) {
                a[i][j] -= Min;
            }
        }
        for (int j = 1; j <= n; ++j) {
            int Min = 1e9;
            for (int i = 1; i <= n; ++i) {
                if (x == i && y == j) continue;
                Min = min(Min, a[i][j]);
            }
            for (int i = 1; i <= n; ++i) {
                a[i][j] -= Min;
            }
        }
        printf("%d\n", -a[x][y]);
    }
    return 0;
}

D. Easy Problem

题意:
定义一个序列\((a_1, a_2, \cdots, a_n)\)是一个\((n, m, d)-good\)当且仅当\(1 \leq a_i \leq m(1 \leq i \leq n)\)并且\(gcd(a_1, a_2, \cdots, a_n) = d\)
令\(f(a, k) = (a_1a_2\cdots a_n)^k\),现在给出\(n, m, d, k\),让你求所有合法的\((n, m, d)-good\)的序列\(a\)的\(f(a, k)\)

思路:
题目要求的东西等价于:
\[
\begin{eqnarray*}
f(d) = \sum\limits_{a_1 = 1}^m \sum\limits_{a_2 = 1}^m \cdots \sum\limits_{a_n = 1}^m [gcd(a_1, a_2, \cdots, a_n) = d](a_1a_2\cdots a_n)^k
\end{eqnarray*}
\]
那么我们令:
\[
\begin{eqnarray*}
g(d) = \sum\limits_{a_1 = 1}^m \sum\limits_{a_2 = 1}^m \cdots \sum\limits_{a_n = 1}^m [d | gcd(a_1, a_2, \cdots, a_n)](a_1a_2\cdots a_n)^k
\end{eqnarray*}
\]
显然有:
\[
\begin{eqnarray*}
g(d) = (\sum\limits_{d\;|\;i} i^k)^n
\end{eqnarray*}
\]
莫比乌斯反演有:
\[
\begin{eqnarray*}
f(d) &=& \sum\limits_{d\;|\;i} \mu(\frac{i}{d})g(i) \&=& \sum\limits_{d\;|\;i} \mu(\frac{i}{d}) (\sum\limits_{i\;|\;j} j^k)^n
\end{eqnarray*}
\]
所以:
\[
f(d) = \sum\limits_{i = 1}^{\left\lfloor m/d \right\rfloor} \mu(i) (\sum\limits_{id\;|\;j} j^k)^n
\]

代码:

view code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10, mod = 59964251;
int pri[N], check[N], mu[N], n, m, d, K, phi;
char s[N];
void sieve() {
    memset(check, 0, sizeof check);
    *pri = 0;
    mu[1] = 1;
    for (int i = 2; i < N; ++i) {
        if (check[i] == 0) {
            pri[++*pri] = i;
            mu[i] = -1;
        }
        for (int j = 1; j <= *pri; ++j) {
            if (i * pri[j] >= N) break;
            check[i * pri[j]] = 1;
            if (i % pri[j] == 0) {
                mu[i * pri[j]] = 0;
                break;
            } else {
                mu[i * pri[j]] = -mu[i];
            }
        }
    }
}

int eular(int n) {
    int ans = n;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            ans -= ans / i;
            while (n % i == 0)
                n /= i;
        }
    }
    if (n > 1) ans -= ans / n;
    return ans;
}

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll qmod(ll base, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) res = res * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return res;
}

int getMod(int mod) {
    int res = 0;
    for (int i = 1; s[i]; ++i) {
        res = (res * 10 + s[i] - '0') % mod;
    }
    return res;
}

int main() {
    phi = eular(mod);
    sieve();
//  cout << phi << endl;
    int _T; scanf("%d", &_T);
    while (_T--) {
        scanf("%s%d%d%d", s + 1, &m, &d, &K);
        int len = strlen(s + 1);
        if (len <= 9) {
            n = 0;
            for (int i = 1; s[i]; ++i) {
                n = n * 10 + s[i] - '0';
            }
        } else {
            n = getMod(phi);
            if (getMod(643) == 0 || getMod(93257) == 0) {
                n += phi;
            }
        }
        ll res = 0;
        for (int i = 1; i <= m / d; ++i) {
            int base = 0;
            for (int j = i * d; j <= m; j += i * d) {
                base += qmod(j, K);
                base %= mod;
            }
            res += 1ll * mu[i] * qmod(base, n) % mod;
            res = (res + mod) % mod;
        }
        printf("%lld\n", res);
    }
    return 0;
}

E. XOR Tree

题意:
定义一个multiset的权值为里面任意两个数的异或和的平方的和。
现在给出一棵有根树(\(1\)为根),每个点有点权,定义\(p(x, k)\)为\(x\)子树中距离\(x\)不超过\(k\)的所有点的点权构成的multiset的权值,现在要对每个\(i \in [1, n]\)求\(p(i, k)\)

F. Function!

G. Pot!!

裸的线段树。

代码:

view code

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, q;
struct SEG {
    struct node {
        int Max, lazy;
        node() { Max = lazy = 0; }
        void up(int x) {
            Max += x;
            lazy += x;
        }
        node operator + (const node &other) const {
            node res = node();
            res.Max = max(Max, other.Max);
            return res;
        }
    }t[N << 2];
    void build(int id, int l, int r) {
        t[id] = node();
        if (l == r) return;
        int mid = (l + r) >> 1;
        build(id << 1, l, mid);
        build(id << 1 | 1, mid + 1, r);
    }
    void down(int id) {
        int &lazy = t[id].lazy;
        if (lazy) {
            t[id << 1].up(lazy);
            t[id << 1 | 1].up(lazy);
            lazy = 0;
        }
    }
    void update(int id, int l, int r, int ql, int qr, int v) {
        if (l >= ql && r <= qr) {
            t[id].up(v);
            return;
        }
        int mid = (l + r) >> 1;
        down(id);
        if (ql <= mid) update(id << 1, l, mid, ql, qr, v);
        if (qr > mid) update(id << 1 | 1, mid + 1, r, ql, qr, v);
        t[id] = t[id << 1] + t[id << 1 | 1];
    }
    int query(int id, int l, int r, int ql, int qr) {
        if (l >= ql && r <= qr) return t[id].Max;
        int mid = (l + r) >> 1;
        down(id);
        int res = 0;
        if (ql <= mid) res = max(res, query(id << 1, l, mid, ql, qr));
        if (qr > mid) res = max(res, query(id << 1 | 1, mid + 1, r, ql, qr));
        return res;
    }
}seg[4];

int main() {
    int id[] = {0, 0, 0, 1, 0, 2, 0, 3, 0};
    vector <vector<int>> vec;
    vec.resize(15);
    for (int i = 2; i <= 10; ++i) {
        int x = i;
        vec[i].clear();
        for (int j = 2; j <= x; ++j) {
            while (x % j == 0) {
                vec[i].push_back(j);
                x /= j;
            }
        }
    //  cout << i << endl;
    //  for (auto &it : vec[i])
    //      cout << it << " ";
    //  cout << endl;
    }
    while (scanf("%d%d", &n, &q) != EOF) {
        for (int i = 0; i < 4; ++i) seg[i].build(1, 1, n);
        char op[20]; int l, r, x;
        while (q--) {
            scanf("%s%d%d", op, &l, &r);
            if (op[1] == 'U') {
                scanf("%d", &x);
                for (auto &it : vec[x]) {
                    seg[id[it]].update(1, 1, n, l, r, 1);
                }
            } else {
                int res = 0;
                for (int i = 0; i < 4; ++i) {
                    res = max(res, seg[i].query(1, 1, n, l, r));
                }
                printf("ANSWER %d\n", res);
            }
        }
    }
    return 0;
}

H. Delivery Route

题意:
给出一张图,有\(x\)条无向边,有\(y\)条有向边,保证无向边都是正权值,有向边可能有负权值,并且保证如果一条有向边\(a_i \rightarrow b_i\),那么在该图中,\(b_i\)不可能到达\(a_i\)
现在询问从\(s\)出发到任意一点的最短路。

思路:
我们考虑如果只考虑有向边,那么是一个\(DAG\),那么把无向边连成的每个联通块看成一个新点,并且有有向边将他们连接起来,他们也是一个\(DAG\)。
并且无向图的连通块里面没有负权边,可以跑dijkstra,然后根据拓扑序dp一下即可。

代码:

view code

#include <bits/stdc++.h>
using namespace std;
using pII = pair<int, int>;
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
#define fi first
#define se second
const int N = 5e4 + 10, INF = 0x3f3f3f3f;
int n, mx, my, s, id[N], d[N];
//0 two-way 1 one-way
vector <vector<pII>> G[3];
vector <vector<int>> po;
struct DSU {
    int fa[N];
    void init() { memset(fa, 0, sizeof fa); }
    int find(int x) {
        return fa[x] == 0 ? x : fa[x] = find(fa[x]);
    }
    void merge(int u, int v) {
        int fu = find(u), fv = find(v);
        if (fu != fv) {
            fa[fu] = fv;
        }
    }
}dsu;

struct node {
    int u, w;
    node() {}
    node(int u, int w) : u(u), w(w) {}
    bool operator < (const node &other) const {
        return w > other.w;
    }
};
int dis[N], used[N];
void Dijkstra(int S) {
    priority_queue <node> pq;
    pq.push(node(S, dis[S]));
    while (!pq.empty()) {
        int u = pq.top().u; pq.pop();
        for (auto &it : G[0][u]) {
            int v = it.fi, w = it.se;
            if (dis[v] > dis[u] + w) {
                dis[v] = dis[u] + w;
                pq.push(node(v, dis[v]));
            }
        }
    }
}

void Topo() {
    queue <int> que;
    for (int i = 1; i <= *id; ++i) {
        if (d[i] == 0) {
            que.push(i);
        }
    }
    while (!que.empty()) {
        int u = que.front(); que.pop();
        sort(po[u].begin(), po[u].end(), [&](int a, int b) { return dis[a] < dis[b]; });
        for (auto &it : po[u]) {
            Dijkstra(it);
            for (auto &it2 : G[1][it]) {
                int v = it2.fi, w = it2.se;
                if (dis[it] < INF) {
                    dis[v] = min(dis[v], dis[it] + w);
                }
            }
        }
        for (auto &it : G[2][u]) {
            int v = it.fi;
            if (--d[v] == 0) {
                que.push(v);
            }
        }
    }
}

int main() {
    while (scanf("%d%d%d%d", &n, &mx, &my, &s) != EOF) {
        for (int i = 1; i <= n; ++i) {
            dis[i] = INF;
        }
        dis[s] = 0;
        *id = 0;
        G[0].clear(); G[1].clear();
        G[0].resize(n + 1); G[1].resize(n + 1);
        for (int i = 1, u, v, w; i <= mx; ++i) {
            scanf("%d%d%d", &u, &v, &w);
            G[0][u].push_back(pII(v, w));
            G[0][v].push_back(pII(u, w));
        }
        for (int i = 1, u, v, w; i <= my; ++i) {
            scanf("%d%d%d", &u, &v, &w);
            G[1][u].push_back(pII(v, w));
        }
        dsu.init();
        for (int u = 1; u <= n; ++u) {
            for (auto &it : G[0][u]) {
                int v = it.fi;
                dsu.merge(u, v);
            }
        }
        for (int u = 1; u <= n; ++u) {
            if (dsu.fa[u] == 0)
                id[u] = ++*id;
        }
        for (int u = 1; u <= n; ++u) {
            if (dsu.fa[u]) {
                id[u] = id[dsu.find(u)];
            }
        }
    //  for (int i = 1; i <= n; ++i)
    //      dbg(i, id[i]);
        po.clear(); po.resize(*id + 10);
        G[2].clear(); G[2].resize(*id + 10);
        memset(d, 0, sizeof d);
        for (int u = 1; u <= n; ++u) {
            po[id[u]].push_back(u);
            for (auto &it : G[1][u]) {
                int v = it.fi;
                if (id[u] != id[v]) {
                    G[2][id[u]].push_back(pII(id[v], v));
                    ++d[id[v]];
                }
            }
        }
        Topo();
        for (int i = 1; i <= n; ++i) {
            if (dis[i] >= INF) puts("NO PATH");
            else printf("%d\n", dis[i]);
        }

    }
    return 0;
}

I. Base62

题意:
进制转换

代码:

view code


def main():
    l = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
         'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
         'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    x, y, z = input().split()
    x = int(x)
    y = int(y)
    num = 0
    for c in z:
        if ord('0') <= ord(c) <= ord('9'):
            num = num * x + ord(c) - ord('0')
        elif ord('A') <= ord(c) <= ord('Z'):
            num = num * x + ord(c) - ord('A') + 10
        else:
            num = num * x + ord(c) - ord('a') + 36
    if num == 0:
        print("0")
        return
    res = ""
    while num > 0:
        tmp = num % y
        res = res + l[tmp]
        num = num // y
    # print(res)
    res = res[::-1]
    print(res)

main()

K. Largest Common Submatrix

题意:
给出两个\(n \cdot m\)的矩形,并且里面的数是\([1, nm]\)的排列。
求两个矩形的最大公共子矩形,这里的大定义为面积。

思路:
考虑里面的数是一个排列,可以\(O(n^2)\)处理出每个数向上拓展多少,向左右拓展多少,然后考虑每一行,肯定是某段连续的长度然后乘上这段最小的向上拓展的数量。
向上拓展的这部分当成一个维,位置当成一维,丢进笛卡尔树里面跑一跑能跑出每个最小值管辖的范围,然后和左右扩展的范围求交,就是每个向上拓展数量在横向最远能扩展的范围。

代码:

view code

#include <bits/stdc++.h>
using namespace std;
using pII = pair<int, int>;
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) { cout << arg << ' '; err(args...); }
#define fi first
#define se second
const int N = 1e3 + 10, INF = 0x3f3f3f3f;
int n, m, a[N][N], b[N][N], l[N][N], r[N][N], num[N][N];
pII c[N], id[N * N];

struct CT {
    struct node {
        int id, val, fa;
        int son[2];
        node() {}
        node (int id, int val, int fa) : id(id), val(val), fa(fa) {
            son[0] = son[1] = 0;
        }
        bool operator < (const node &other) const {
            return val < other.val;
        }
    }t[N];
    int root;
    void init() {
        t[0] = node(0, -INF, 0);
    }
    void build(int n, int *a) {
        for (int i = 1; i <= n; ++i) {
            t[i] = node(i, a[i], 0);
        }
        for (int i = 1; i <= n; ++i) {
            int k = i - 1;
            while (t[i] < t[k]) {
                k = t[k].fa;
            }
            t[i].son[0] = t[k].son[1];
            t[k].son[1] = i;
            t[i].fa = k;
            t[t[i].son[0]].fa = i;
        }
        root = t[0].son[1];
    }
    int dfs(int u) {
        if (!u) return 0;
        c[u].fi = dfs(t[u].son[0]);
        c[u].se = dfs(t[u].son[1]);
        return c[u].fi + c[u].se + 1;
    }
}ct;

int main() {
    while (scanf("%d%d", &n, &m) != EOF) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                scanf("%d", &a[i][j]);
            }
        }
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                scanf("%d", &b[i][j]);
                id[b[i][j]] = pII(i, j);
            }
        }

        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                if (j == 1) {
                    l[i][j] = j;
                } else {
                    int pre = a[i][j - 1], now = a[i][j];
                    if (id[pre].fi == id[now].fi && id[pre].se == id[now].se - 1) {
                        l[i][j] = l[i][j - 1];
                    } else {
                        l[i][j] = j;
                    }
                }
            }
            for (int j = m; j >= 1; --j) {
                if (j == m) {
                    r[i][j] = j;
                } else {
                    int nx = a[i][j + 1], now = a[i][j];
                    if (id[nx].fi == id[now].fi && id[nx].se == id[now].se + 1) {
                        r[i][j] = r[i][j + 1];
                    } else {
                        r[i][j] = j;
                    }
                }
            }
        }
        for (int j = 1; j <= m; ++j) {
            for (int i = 1; i <= n; ++i) {
                if (i == 1) {
                    num[i][j] = 1;
                } else {
                    int pre = a[i - 1][j], now = a[i][j];
                    if (id[pre].fi == id[now].fi - 1 && id[pre].se == id[now].se) {
                        num[i][j] = num[i - 1][j] + 1;
                    } else {
                        num[i][j] = 1;
                    }
                }
            }
        }
        int res = 0;
        for (int i = 1; i <= n; ++i) {
        //  for (int j = 1; j <= m; ++j) {
        //      dbg(i, j, l[i][j], r[i][j], num[i][j]);
        //  }
            ct.init();
            ct.build(n, num[i]);
            ct.dfs(ct.root);
            for (int j = 1; j <= m; ++j) {
                int tl = max(l[i][j], j - c[j].fi);
                int tr = min(r[i][j], j + c[j].se);
                res = max(res, (tr - tl + 1) * num[i][j]);
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

N. Fibonacci Sequence

纯输出题

原文地址:https://www.cnblogs.com/Dup4/p/11963769.html

时间: 2024-08-30 07:01:55

2019 ICPC Asia Yinchuan Regional的相关文章

2019 ICPC Asia Nanjing Regional 重现赛

C. Digital Path 题意: 给出一个网格,格子里面有各自的值,要求找出有多少条线路,是从某一个块四周自己最小开始走到某一个块,四周自己最大并且长度大于等于四. 解:显然,对于某一块,我们判断他能不能成为起点,就可以判断他的上下左右是否比他小1,比他小1那么肯定不能作为起点.判断终点同理. 那么针对每一个起点,我们首先暴力dfs,判断他的上下左右是否满足比他刚好大1,有的话继续dfs下去. 这样我们得到了一个暴力算法然后考虑优化. 令dp[i][j][len]表示,第(i,j)块,作为

2019 ICPC Asia Nanjing Regional F. Paper Grading

题目链接:https://nanti.jisuanke.com/t/42400 题意:给一个模式串集合,序号1~n,有T个操作,或者是交换序号,或者是查询模式串集合中序号在L到R之 间的字符串有多少个和目标串公共前缀长度大于等于K. --------------------------------- 对模式串集合建字典树,则与目标串\(LCP\)大于等K的字符串,都在以目标串第\(K\)个字符所在的结点为根的子树中,每个模式串插入字典树的过程中记录序号,修改时交换序号,询问就相于在子树中询问有多

The 2019 ICPC Asia Shanghai Regional Contest-B-Prefix Code

知识点:字典树. 题目链接: https://ac.nowcoder.com/acm/contest/4370/B 题意:t组数据,n个数字,问是否满足不存在任何一个数字是其他数字的前缀. 题解:套用字典树一个一个插入字符串.若在插入过程中遇到如下两种情况,则存在其中一个是另一个的前缀. 1.遍历完整个字符串都没有创造新的节点,说明该字符串是之前某个串的字串. 2.遍历过程中遇到了某个字符串的终点,说明存在一个字符串是该字符串的前缀. 若都不存在,则满足条件. AC代码: 1 #include

The 2019 ICPC Asia Shanghai Regional Contest---H Tree Partition 二分答案,从下往上切最大子树

题意:https://ac.nowcoder.com/acm/contest/4370 将一棵树切k-1刀分成k棵树,问这k棵树里最大的权值的最小值是多少 思路:https://www.cnblogs.com/ucprer/p/11931263.html 二分最大值. dfs割子树,每次从下往上切一个最大的树. 单个dfs表示保证当前节点可切,然后子树dfs完了,sort子树,选最大的切,直到当前u节点也可切 1 #define IOS ios_base::sync_with_stdio(0);

The 2019 ICPC Asia Shanghai Regional Contest-C-Spanning Tree Removal

知识点:构造.思维. 题目链接:https://ac.nowcoder.com/acm/contest/4370/D 题意:n点完全图,每次可以删除一个生成树的边,问最多可以删几次,并构造出其中一种. 题解:给出一种删边方式可以尽可能多次的删除:第i次:从i开始.依次删除i-(i+1)-(i-1)-(i+2)-(i-2)-…… 直到连接完所有点为止.总共可以删除n/2次. AC代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 i

2018-2019, ICPC, Asia Yokohama Regional Contest 2018 (Gym - 102082)

2018-2019, ICPC, Asia Yokohama Regional Contest 2018 A - Digits Are Not Just Characters 签到. B - Arithmetic Progressions 题意:从给定的集合中选出最多的数构成等差数列. 题解:数字排序后,设\(dp[i][j]\)表示等差数列最后一个数字为\(a[i]\),倒数第二个数字为\(a[j]\)的最大个数.然后对于每一位枚举 \(i\),\(lower\_bound()\)找有无合法的

2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)

题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine the area of the largest triangle that can be formed using \(3\) of those \(N\) points. If there is no triangle that can be formed, the answer is \(0\

The Preliminary Contest for ICPC Asia Yinchuan 2019

目录 Solutions Link Solutions 题意: 思路: 代码: [] 原文地址:https://www.cnblogs.com/c4Lnn/p/12333659.html

比赛:ICPC Asia Taipei-Hsinchu Regional 2019 2020.4.1

C. Are They All Integers? 题意:是给定n个数字判断对任意的(a[j]-a[i])/a[k]一定要是整数. 题解: 一开始以为用枚举会超时不过还是试了下,没想到没超时,直接过了,题目很简单,简单枚举就好. #include<iostream> using namespace std; int main(){ int n,a[1001],sum; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(i