Codeforces Round #666 (Div. 2) 题解报告
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) 题解报告的更多相关文章
- Codeforces Round #182 (Div. 1)题解【ABCD】
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #665 (Div. 2) 题解
Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...
- Codeforces Round #532 (Div. 2) 题解
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...
- Codeforces Round #160 (Div. 1) 题解【ABCD】
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...
- 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 题解 直接 ...
随机推荐
- Android 实现APP可切换多语言
原文: Android 实现APP可切换多语言 - Stars-One的杂货小窝 如果是单独给app加上国际化,其实很容易,创建对应的国家资源文件夹即可,如values-en,values-pt,ap ...
- 论文阅读:2023_Semantic Hearing: Programming Acoustic Scenes with Binaural Hearables
论文地址:语义听觉:用双耳可听器编程声学场景 论文代码:https://semantichearing.cs.washington.edu/ 引用格式:Veluri B, Itani M, Chan ...
- 用JS实现简单的屏幕录像机
本文将介绍如何用JS实现简单的屏幕录像机. 一.录制准备 创建一个按钮 <button id="recording-toggle">Start recording< ...
- postman——下载与安装
一.postman是什么? 那么,Postman是个什么东东呢?Postman的官网上这么介绍它:"Modern software is built on APIs,Postman help ...
- elastic常用api
elasticsearch运维常用API 查看集群状态 查询集群状态命令: curl -XGET "http://ip:port/_cluster/health?pretty" # ...
- Java 并发编程(七)线程池
任务的创建与执行 在多线程的编程环境中,理想的情况是每个任务之间都存在理想的边界,各个任务之间相互独立,这样才能够享受到并发带来的明显的性能提升,并且,由于每个任务之间如果都是独立的,对于并发的处理也 ...
- STM32CubeMX教程12 DMA 直接内存读取
使用STM32CubeMX软件配置STM32F407开发板上串口USART1进行DMA传输数据,然后实现与实验"STM32CubeMX教程9 USART/UART 异步通信"相同的 ...
- 开源云原生网关Linux Traefik本地部署结合内网穿透远程访问
开源云原生网关Linux Traefik本地部署结合内网穿透远程访问 前言 Træfɪk 是一个云原生的新型的 HTTP 反向代理.负载均衡软件,能轻易的部署微服务.它支持多种后端 (Docker ...
- 从C++CLI工程的依赖库引用问题看.Net加载程序集机制
问题 最近在为某第三方MFC项目写C++/CLI工程插件时遇到了如下一个问题: MFC的工程不允许把.Net的依赖程序集放到执行程序的目录(防止影响其稳定性),依赖库只能放到非执行程序子目录的其他目录 ...
- C# 将Excel转为OFD、UOS
本文以C#及VB.NET代码为例展示如何将Excel工作簿转换为OFD和UOS格式.通过workbook.LoadFromFile(string fileName)方法加载Excel源文档后,然后调用 ...