AtCoder Grand Contest 035 – 解题报告

A – XOR Circle

考虑对仅有的 \(s \leq 3\) 个元素排列顺序然后判就完事了。

// A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, ai[MAX_N], si[MAX_N];
map<int, int> mp, tmp;

int main()
{
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++)
        scanf("%d", &ai[i]), mp[ai[i]]++;
    if (mp.size() <= 3)
    {
        vector<int> vi;
        for (auto x : mp)
            vi.push_back(x.first);
        bool flag = false;
        do
        {
            int len = vi.size();
            tmp.clear();
            for (int i = 1; i <= 2; i++)
                si[i] = vi[(i - 1) % len];
            for (int i = 3; i <= n; i++)
                si[i] = si[i - 1] ^ si[i - 2];
            for (int i = 1; i <= n; i++)
                tmp[si[i]]++;
            bool cflag = true;
            for (auto x : tmp)
                cflag &= mp[x.first] == x.second;
            flag |= cflag;
        } while (next_permutation(vi.begin(), vi.end()));
        puts(flag ? "Yes" : "No");
    }
    else
        puts("No");
    return 0;
}
Continue reading →

AtCoder Grand Contest 036 – 解题报告

A – Triangle

三角形斜着放即可。

// A.cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll S;

int main()
{
	scanf("%lld", &S);
	ll y = (S + int(1e9) - 1) / int(1e9), x = y * int(1e9) - S;
	printf("%d %d %d %d %lld %lld\n", 0, 0, int(1e9), 1, x, y);
	return 0;
}
Continue reading →

「Codeforces 653G」Move by Prime – 题解

主要思路

这些 3000+ 题目里做过最小清新的。

首先肯定可以想到,分解质因子之后,对于一个 \(p^c\),把每个元素该质因子的指数拿出来做中位数即为此质因子的贡献。我大概想到这里就断片了。

Continue reading →