https://codeforces.com/contest/1397/problem/A

    Codeforces Round #666 (Div. 2) 题解报告 - 图1

    题意:

    给定n个字符串,问重新组合以后是否能构成相同的n个字符串

    思路:

    直接判断所给的字符串的每种字母是否能被n整除即可。

    1. //稍微写复杂了
    2. #include<bits/stdc++.h>
    3. #define ms(a,b) memset(a,b,sizeof a)
    4. using namespace std;
    5. typedef long long ll;
    6. const int N = 1e5 + 100;
    7. ll n, m, a[N], i, j;
    8. void solve() {
    9. ms(a, 0);
    10. cin >> n;
    11. string s; ll cnt = 0;
    12. for (int i = 0; i < n; ++i) {
    13. cin >> s; for (int j = 0; j < s.length(); ++j) {
    14. a[s[j] - 'a']++;
    15. }
    16. cnt += s.length();
    17. }
    18. if (cnt % n != 0)cout << "NO" << endl;
    19. else {
    20. for(int i = 0;i < 26;++i)
    21. if (a[i] % n != 0) {
    22. cout << "NO" << endl;
    23. return;
    24. }
    25. cout << "YES" << endl;
    26. }
    27. }
    28. int main() {
    29. //freopen("in.txt", "r", stdin);
    30. ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    31. int t; cin >> t;
    32. while (t--) solve();
    33. }

    https://codeforces.com/contest/1397/problem/B

    Codeforces Round #666 (Div. 2) 题解报告 - 图2

    题意:

    利用每次代价都为1的Codeforces Round #666 (Div. 2) 题解报告 - 图3 or Codeforces Round #666 (Div. 2) 题解报告 - 图4 构建幂序列。

    1. #include<bits/stdc++.h>
    2. using namespace std;
    3. typedef long long ll;
    4. ll a[100100], n;
    5. ll ans = 0x3f3f3f3f3f3f3f3f;
    6. int main() {
    7. //freopen("in.txt", "r", stdin);
    8. ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    9. cin >> n; for (int i = 1; i <= n; ++i)cin >> a[i];
    10. int lim = pow(1e18, 1.0 / n);
    11. sort(a + 1, a + 1 + n);
    12. for (int i = 1; i <= lim; i++) {
    13. ll now = 0, k = 1;
    14. for (int j = 1; j <= n; ++j) {
    15. now += abs(k - a[j]);
    16. k *= i;
    17. }
    18. ans = min(ans, now);
    19. }
    20. cout << ans << endl;
    21. }

    https://codeforces.com/contest/1397/problem/C

    Codeforces Round #666 (Div. 2) 题解报告 - 图5

    没有做出,先贴一下dalao代码

    1. #include<iostream>
    2. using namespace std;
    3. int main(){
    4. long long n; cin >> n;
    5. long long a[n + 1];
    6. for (int i = 1; i <= n; i++)
    7. cin >> a[i];
    8. cout << "1 1" << endl << a[1] * (n - 1) << endl;
    9. (n == 1) ? cout << "1 1" << endl << "0" : cout << "2 " << n << endl;
    10. for (int i = 2; i <= n; i++)
    11. cout << a[i] * (n - 1) << " ";
    12. cout << endl << "1 " << n << endl;
    13. for (int i = 1; i <= n; i++)
    14. cout << -a[i] * n << " ";
    15. }

    https://codeforces.com/contest/1397/problem/D

    题意:

    T和HL玩游戏,再给定的石堆中选择一个(但不能是上一个人取的那堆)取一个石子。一旦有一方不能取石头则判输

    思路:

    博弈问题,先统计所有石头数,如果sum小于mx(最多石头的一堆)的两倍或者sum为奇数则必然是T能赢,不然就是HL赢

    1. #include<bits/stdc++.h>
    2. using namespace std;
    3. int main() {
    4. //freopen("in.txt", "r", stdin);
    5. ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    6. int t; cin >> t;
    7. while (t--) {
    8. int n; cin >> n;
    9. int sum = 0, mx = 0;
    10. while (n--) {
    11. int x; cin >> x;
    12. sum += x;
    13. if (x > mx)mx = x;
    14. }
    15. if (sum - mx < mx || sum % 2 == 1)cout << "T\n";
    16. else cout << "HL\n";
    17. }
    18. }