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

题意:
给定n个字符串,问重新组合以后是否能构成相同的n个字符串
思路:
直接判断所给的字符串的每种字母是否能被n整除即可。
//稍微写复杂了#include<bits/stdc++.h>#define ms(a,b) memset(a,b,sizeof a)using namespace std;typedef long long ll;const int N = 1e5 + 100;ll n, m, a[N], i, j;void solve() {ms(a, 0);cin >> n;string s; ll cnt = 0;for (int i = 0; i < n; ++i) {cin >> s; for (int j = 0; j < s.length(); ++j) {a[s[j] - 'a']++;}cnt += s.length();}if (cnt % n != 0)cout << "NO" << endl;else {for(int i = 0;i < 26;++i)if (a[i] % n != 0) {cout << "NO" << endl;return;}cout << "YES" << endl;}}int main() {//freopen("in.txt", "r", stdin);ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t; cin >> t;while (t--) solve();}
https://codeforces.com/contest/1397/problem/B

题意:
利用每次代价都为1的 or
构建幂序列。
#include<bits/stdc++.h>using namespace std;typedef long long ll;ll a[100100], n;ll ans = 0x3f3f3f3f3f3f3f3f;int main() {//freopen("in.txt", "r", stdin);ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);cin >> n; for (int i = 1; i <= n; ++i)cin >> a[i];int lim = pow(1e18, 1.0 / n);sort(a + 1, a + 1 + n);for (int i = 1; i <= lim; i++) {ll now = 0, k = 1;for (int j = 1; j <= n; ++j) {now += abs(k - a[j]);k *= i;}ans = min(ans, now);}cout << ans << endl;}
https://codeforces.com/contest/1397/problem/C

没有做出,先贴一下dalao代码
#include<iostream>using namespace std;int main(){long long n; cin >> n;long long a[n + 1];for (int i = 1; i <= n; i++)cin >> a[i];cout << "1 1" << endl << a[1] * (n - 1) << endl;(n == 1) ? cout << "1 1" << endl << "0" : cout << "2 " << n << endl;for (int i = 2; i <= n; i++)cout << a[i] * (n - 1) << " ";cout << endl << "1 " << n << endl;for (int i = 1; i <= n; i++)cout << -a[i] * n << " ";}
https://codeforces.com/contest/1397/problem/D
题意:
T和HL玩游戏,再给定的石堆中选择一个(但不能是上一个人取的那堆)取一个石子。一旦有一方不能取石头则判输
思路:
博弈问题,先统计所有石头数,如果sum小于mx(最多石头的一堆)的两倍或者sum为奇数则必然是T能赢,不然就是HL赢
#include<bits/stdc++.h>using namespace std;int main() {//freopen("in.txt", "r", stdin);ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t; cin >> t;while (t--) {int n; cin >> n;int sum = 0, mx = 0;while (n--) {int x; cin >> x;sum += x;if (x > mx)mx = x;}if (sum - mx < mx || sum % 2 == 1)cout << "T\n";else cout << "HL\n";}}
