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. python 迭代器(转)

    迭代器 迭代器是在python2.2中被加入的,它为类序列对象提供了一个类序列的接口.有了迭代器可以迭代一个不是序列的对象,因为他表现出了序列的行为.当在python中使用for循环迭代一个对象时,调 ...

  2. Ceph Bluestore首测

    Bluestore 作为 Ceph Jewel 版本推出的一个重大的更新,提供了一种之前没有的存储形式,一直以来ceph的存储方式一直是以filestore的方式存储的,也就是对象是以文件方式存储在o ...

  3. 在Service中创建全局Dialog对话框

    需要使用到悬浮窗权限 val builder: AlertDialog.Builder = AlertDialog.Builder(this)builder.setMessage("from ...

  4. 一个Wpf的开发框架

    引言 本框架使用Prism做MVVM,优点咱就不说了,主要了容器注入,消息和DI,比自己写省很多事.网上有很多标准的MVVM的使用方法,但是没有形成一个系统级的框架.本框架从登录到具体业务的使用,还有 ...

  5. phpmyadmin 4.8.1任意文件包含(CVE-2018-12613)

    简介 环境复现:https://gitee.com/xiaohua1998/hctf_2018_warmup 考察知识点:文件包含漏洞(phpmyadmin 4.8.1任意文件包含) 线上平台:榆林学 ...

  6. python多线程——如何停止一个死循环的线程

    进程想要执行任务就需要依赖线程.换句话说,就是进程中的最小执行单位就是线程,并且一个进程中至少有一个线程. 那什么是多线程?提到多线程这里要说两个概念,就是串行和并行,搞清楚这个,我们才能更好地理解多 ...

  7. java中对于浮点型数据操作

    java的基本数据类型-浮点型:单精度(float)和双精度(double). float:单精度浮点数在机内占4个字节.有效数字8位.表示范围:-3.40E+38 ~ +3.40E+38; doub ...

  8. EasyRecovery帮您轻松拯救办公室断电后的文件丢失

    故事要从半个月前说起,某天中午,社畜小编得到了上头的传令,要为即将到来的双十一狂欢节写一个活动策划案. 想着时间也不是很充裕,还要留一些时间修修补补,于是小编连续三天挑灯夜战,终于在某天周五的晚上把策 ...

  9. 在FL Studio中有序地处理人声的混音轨道

    关于人声处理的技巧,我们在以前也有讲到很多,当然在以后也会有新的人声处理技巧课程,这是在音乐后期制作中无法避免的一个环节,在制作许多流行音乐时都会用到,今天先为大家讲解一下在FL Studio中更有序 ...

  10. FL studio系列教程(一):什么是FL水果音乐制作软件

    如今,越来越多的音乐人选择使用音乐制作软件来进行音乐的创作,一台电脑.一款软件以及一个外接MIDI就是一个小型的音乐工作站.FL Studio成了音乐界萌新的首选,目前最新的版本为FL Studio2 ...