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的更多相关文章

  1. Codeforces Beta Round #59 (Div. 2)

    Codeforces Beta Round #59 (Div. 2) http://codeforces.com/contest/63 A #include<bits/stdc++.h> ...

  2. Educational Codeforces Round 59 (Rated for Div. 2) DE题解

    Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...

  3. Codeforces Beta Round #55 (Div. 2)

    Codeforces Beta Round #55 (Div. 2) http://codeforces.com/contest/59 A #include<bits/stdc++.h> ...

  4. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  5. 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]中有多少个数 ...

  6. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  7. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  8. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  9. Codeforces Global Round 1 - D. Jongmah(动态规划)

    Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...

随机推荐

  1. linux nf_conntrack 连接跟踪机制

    PRE_ROUTING和LOCAL_OUT点可以看作是整个netfilter的入口,而POST_ROUTING和LOCAL_IN可以看作是其出口; 报文到本地:PRE_ROUTING----LOCAL ...

  2. parted命令采用gpt分区过程

    Gpt无分区限制,故只有主分区,无扩展分区和逻辑分区.分区直接按容量算,不按柱面算. 查看分区:parted -l 将分区表类型转换为gpt.: 主要命令mklabel gpt 对sdc盘分区: [r ...

  3. NOIP前一些题目的理解

    ZYB和售货机(图论,环) 题目链接 个人感觉这道题与基环树没有任何关系,你会发现,每个点最多只有一个入度和出度,所以只能是链或环. 还有就是本题的突破点就在于正确建图,题目的限制保证每个点的入度不大 ...

  4. 服务器虚拟化 - PVE

    服务器虚拟化 - Hypervisor 服务器虚拟化软件,也叫 Hypervisor--虚拟机管理程序,有时也称做 Virtual Machine Monitor(VMM),它可以在宿主机上创建并管理 ...

  5. Python_爬虫项目

    1.爬虫--智联招聘信息搜集    原文链接 1 #-*- coding: utf-8 -*- 2 import re 3 import csv 4 import requests 5 from tq ...

  6. Linux——CentOS 7 systemctl和防火墙firewalld命令

    一.防火墙的开启.关闭.禁用命令 (1)设置开机启用防火墙:systemctl enable firewalld.service (2)设置开机禁用防火墙:systemctl disable fire ...

  7. DockerPush

    1.阿里云镜像发布流程 2.镜像生成 语法:docker commit [OPTIONS] 容器ID [REPOSITORY[:TAG]] [root@pluto data]# docker imag ...

  8. Android10_原理机制系列_AMS(ATMS)之应用的第一次启动的过程

    概述 该篇基于Android 10的代码.在 AMS之AMS的启动---Android Framework(Android 10) 中已经介绍了,在Android 10中,activity的调度和管理 ...

  9. (msf使用)msfconsole - meterpreter

    [msf] msfconsole meterpreter 对于这款强大渗透测试框架,详情介绍可看这里:metasploit 使用教程 对于msfconsole, Kali Linux 自带.只需用命令 ...

  10. 记录一次tomcat问题排查记录:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

    最近项目升级jdk,从jdk7 升级到 jdk8,本地已经自测完成了,需要部署到测试环境,测试环境已经装好 jdk8 了,但是tomcat 的版本还是 7.不过,据我之前了解,tomcat7是可以运行 ...