Codeforces Edu Round 59 A-D
A. Digits Sequence Dividing
注意特殊情况,在\(n = 2\)时除非\(str[1] >= str[2]\),否则可以把第一个数划分下来,剩下的数直接当成一组,一定满足条件。
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
const int N = 310;
int n;
char s[N];
int main(){
int T; scanf("%d", &T);
while(T--){
scanf("%d%s", &n, s + 1);
if(n == 2){
if(s[1] >= s[2]) puts("NO");
else printf("YES\n2\n%c %c\n", s[1], s[2]);
}else{
printf("YES\n2\n%c ", s[1]);
for(int i = 2; i <= n; i++) putchar(s[i]);
puts("");
}
}
return 0;
}
B. Digital root
通过打表找规律发现的…看了题解,证明还是很NB的...
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
int main(){
int T; scanf("%d", &T);
while(T--){
LL k, x; scanf("%lld%lld", &k, &x);
printf("%lld\n", (k - 1) * 9 + x);
}
return 0;
}
C. Brutality
用堆维护连续子段最大和即可。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 200010;
int n, k, a[N];
LL ans = 0;
char s[N];
priority_queue<int, vector<int>, greater<int> > q;
int main(){
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++) scanf("%d", a + i);
scanf("%s", s + 1);
for(int i = 1; i <= n; i++){
if(s[i] != s[i - 1]){
while(!q.empty()) ans += q.top(), q.pop();
q.push(a[i]);
}else{
q.push(a[i]);
}
while(q.size() > k) q.pop();
}
while(!q.empty()) ans += q.top(), q.pop();
printf("%lld\n", ans);
return 0;
}
D. Compression
实质上是把这图压缩到最小的点阵图,用\(bitset\)优化复杂度,暴力水过。
#include <cstdio>
#include <iostream>
#include <bitset>
using namespace std;
const int N = 5210;
bitset<N> a[N];
int n;
//密集恐惧症
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j += 4){
char x; cin >> x;
//16进制转2进制
if(x == '1') a[i][j + 3] = 1;
else if(x == '2') a[i][j + 2] = 1;
else if(x == '3') a[i][j + 2] = a[i][j + 3] = 1;
else if(x == '4') a[i][j + 1] = 1;
else if(x == '5') a[i][j + 1] = a[i][j + 3] = 1;
else if(x == '6') a[i][j + 2] = a[i][j + 3] = 1;
else if(x == '7') a[i][j + 1] = a[i][j + 2] = a[i][j + 3] = 1;
else if(x == '8') a[i][j] = 1;
else if(x == '9') a[i][j] = a[i][j + 3] = 1;
else if(x == 'A') a[i][j] = a[i][j + 2] = 1;
else if(x == 'B') a[i][j] = a[i][j + 2] = a[i][j + 3] = 1;
else if(x == 'C') a[i][j] = a[i][j + 1] = 1;
else if(x == 'D') a[i][j] = a[i][j + 1] = a[i][j + 3] = 1;
else if(x == 'E') a[i][j] = a[i][j + 1] = a[i][j + 2] = 1;
else if(x == 'F') a[i][j] = a[i][j + 1] = a[i][j + 2] = a[i][j + 3] = 1;
}
}
for(int x = n; x >= 2; x--){
if(n % x) continue;
bool ep = true;
for(int i = 1; i <= n; i += x){
for(int j = i + 1; j < i + x; j++){
ep = ep && (a[j] == a[i]);
if(!ep) break;
}
if(!ep) break;
for(int j = 1; j <= n; j += x){
for(int k = j + 1; k < j + x; k++){
ep = ep && (a[i][k] == a[i][k - 1]);
if(!ep) break;
}
if(!ep) break;
}
if(!ep) break;
}
if(ep) { cout << x; return 0; }
}
cout << 1;
return 0;
}
Codeforces Edu Round 59 A-D的更多相关文章
- Codeforces Beta Round #59 (Div. 2)
Codeforces Beta Round #59 (Div. 2) http://codeforces.com/contest/63 A #include<bits/stdc++.h> ...
- Educational Codeforces Round 59 (Rated for Div. 2) DE题解
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...
- Codeforces Beta Round #55 (Div. 2)
Codeforces Beta Round #55 (Div. 2) http://codeforces.com/contest/59 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #62 题解【ABCD】
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- CodeForces Global Round 1
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...
- Codeforces Global Round 1 - D. Jongmah(动态规划)
Problem Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...
随机推荐
- MFC常用函数
1.MFC的常用函数(只是找了些经常使用的,这里没有的可以CSDN查找,不需要都记住,经常使用自动就会记得) 1)GetDlgItemText(ID ,str)作用: 对话框中获取文本第一个参数为要获 ...
- DockerInstall
1.安装Tomcat 2.安装mysql [1].pull [root@pluto tomcat7logs]# docker pull mysql:5.6 [root@pluto tomcat7log ...
- centos 6 系统下同步本地时间
1.date显示系统时间 [root@oldboy ~]# dateTue Mar 31 22:45:55 CST 2020 #CST是指是指某中标准时间 非东八区时间 更改时间的三种方法 1.c ...
- spark任务执行流程
standlone模式 yarn模式 对比:
- 阿里面试官:小伙子,你给我说一下Spring Bean初始化的几种常规方式吧
前言 通过构造方法实例化通过静态工厂实例化通过实例工厂实例化通过FactoryBean实例化 RumenzA实体类 package com.rumenz; public class RumenzA { ...
- 主板上来了一个新邻居,CPU慌了!
大家好,我是CPU一号车间的那个阿Q,好久不见,我想死你们了- 不认识我的请去这里这里补补课:完了!CPU一味求快出事儿了! 主板上的新邻居 "阿Q,快别忙了,马上去一趟会议室,领导有重要事 ...
- ABBYY FineReader 15新增智能PDF文档转换功能
ABBYY FineReader 15(Windows系统)新增智能PDF文档转换功能,可自动检测导入PDF数字文档的文本层质量,确保转变为可编辑格式后的准确结果:从表单字段和文本框中提取文本,准确保 ...
- CorelDRAW常用工具之手绘工具
对于平面设计师来说,一个好用顺手的手绘工具是必不可少的,CorelDRAW的手绘工具能将手绘笔触转换成平滑的线条或者形状. 1.基础操作 CorelDRAW的手绘工具组包含手绘.2点线.贝塞尔.钢笔. ...
- Logstash使用mongodb插件报错: ArgumentError: wrong number of arguments (given 2, expected 1)
目录 背景 安装插件过程 背景 今天在使用logstash收集日志存储到mongodb的安装过程遇到了个错误,记录下来,错误就是下面这样: 配置文件很简单,由于是测试环境,命令行传入日志输入由ruby ...
- 一个定时任务管理器,基于Go语言和beego框架开发
链接 https://github.com/lisijie/webcron 安装说明 系统需要安装Go和MySQL. 获取源码 $ go get github.com/lisijie/webcron ...