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的\(a_i + 1\) or \(a_i - 1\) 构建幂序列。

#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";
}
}

Codeforces Round #666 (Div. 2) 题解报告的更多相关文章

  1. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  2. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  3. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  4. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  5. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  6. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  7. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  8. Codeforces Round #532 (Div. 2) 题解

    Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...

  9. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

  10. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

随机推荐

  1. 【luogu题解】P9749 [CSP-J 2023] 公路

    \(Meaning\) \(Solution\) 这道题我来讲一个不一样的解法:\(dp\) 在写 \(dp\) 之前,我们需要明确以下几个东西:状态的表示,状态转移方程,边界条件和答案的表示. 状态 ...

  2. Jayway JsonPath-提取JSON文档内容的Java DSL

    介绍 JsonPath是一种能够提取部分JSON文档属性.对象.数组的语法,支持条件过滤.数学运算.字符串处理等功能.JsonPath与JSON文档就像 XPath 表达式与 XML 文档结合使用一样 ...

  3. Acwing4244牛的比赛

    Acwing4244.牛的比赛 题目部分 N 头奶牛,编号 1∼N,一起参加比赛. 奶牛的战斗力两两不同. 这些奶牛之间已经进行了 M轮两两对决. 在对决中,战斗力高的奶牛一定会战胜战斗力低的奶牛. ...

  4. MySQL笔记01: MySQL入门_1.3 MySQL启动停止与登录

    1.3 MySQL启动停止与登录 1.3.1 MySQL启动与停止 MySQL数据库分为客户端和服务器端,只有服务器端服务开启以后,才可以通过客户端登录MySQL服务端. 首先,以管理员身份运行&qu ...

  5. echarts设置多条折线不是你想的那样简单

    简单的多条折线图 小伙伴写过多条折线图的都知道, 常见的折线图是 xAxis 配置项下的 data属性上设置时间或者日期. series配置项下是对应的 legend中的数据以及该条折线的数据. &l ...

  6. 微信现金红包开发 PHP

    第一次在cnblogs发文章 微信商家后台-现金红包开发 sdk <?php class wxPay { //配置参数信息 const SHANGHUHAO = "1430998xxx ...

  7. 华硕AX系列路由器选购,以及华硕WIFI6路由器智能设备家电无法互联的解决方法。

    家里昨天换了一整套wifi6路由器(华硕AX82U+XD4R),刚刚换上就发现原来的欧普智能灯和部分其他设备无法使用了,而小米等设备等都可以互联,智能家居绝大部分用的是2.4G的协议,所以说,问题出现 ...

  8. window10 AppX Deployment Service (AppXSVC)占用大量内存导致资源管理器卡死无响应

    window10 AppX Deployment Service (AppXSVC)占用大量内存导致资源管理器卡死无响应,导致无法进入桌面打开软件等等. 1.打开任务管理的情况下,先结束卡死的资源管理 ...

  9. 2023-11-29:用go语言,给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次。 需保证 返回结果的字典序最小。 要求不能打乱其他字符的相对位置)。 输入:s = “cba

    2023-11-29:用go语言,给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次. 需保证 返回结果的字典序最小. 要求不能打乱其他字符的相对位置). 输入:s = &quo ...

  10. 文心一言 VS 讯飞星火 VS chatgpt (57)-- 算法导论6.4 1题

    文心一言 VS 讯飞星火 VS chatgpt (57)-- 算法导论6.4 1题 一.参照图 6-4 的方法,说明 HEAPSORT 在数组 A=(5,13,2,25,7,17,20,8,4)上的操 ...