CodeForces Round #555 Div.3
A. Reachable Numbers
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e9 + ;
int N;
set<int> s; int main() {
scanf("%d", &N);
while(s.find(N) == s.end()) {
s.insert(N);
N += ;
while(N % == ) N /= ;
} printf("%d\n", (int) s.size()); return ;
}
B. Long Number
代码:
#include <bits/stdc++.h>
using namespace std; int N;
string s;
int a[]; int main() {
scanf("%d", &N);
cin >> s;
for(int i = ; i <= ; i ++) {
int x;
scanf("%d", &x);
a[i] = x;
} for(int i = ; i < N; i ++) {
if(a[s[i] - ''] > s[i] - '') {
for(int j = i; j < N; j ++) {
if(a[s[j] - ''] >= s[j] - '')
s[j] = a[s[j] - ''] + '';
else break;
}
break;
}
} cout << s << endl; return ;
}
C1. Increasing Subsequence (easy version)
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]);
string ans = ""; int l = , r = N - , pos = ;
while(l <= r) {
if(a[l] < a[r]) {
if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else break;
} else {
if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else break;
}
} printf("%d\n", ans.length());
cout << ans << endl; return ;
}
C2. Increasing Subsequence (hard version)
代码(在两边一样的情况下只能选左或右跑了):
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int pos = ;
int a[maxn];
string ans1 = "", ans2 = "", ans = ""; string Left(int st, int en, string s) {
string t = s;
int l = st, r = en;
while(l <= r) {
if(a[l] > pos) {
pos = a[l];
l ++;
t += 'L';
} else break;
}
return t;
} string Right(int st, int en, string s) {
string t = s;
int l = st, r = en;
while(l <= r) {
if(a[r] > pos) {
pos = a[r];
r --;
t += 'R';
} else break;
}
return t;
} int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]); int l = , r = N - ;
int tp = ;
while(l <= r) {
if(a[l] < a[r]) {
if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else break;
} else if(a[l] > a[r]) {
if(a[r] > pos) {
pos = a[r];
r --;
ans += 'R';
} else if(a[l] > pos) {
pos = a[l];
l ++;
ans += 'L';
} else break;
} else {
int poo = pos;
ans1 = ans, ans2 = ans;
ans1 = Left(l, r, ans);
pos = poo;
ans2 = Right(l, r, ans);
if(ans1.length() > ans2.length())
//cout << ans1 << endl;
ans = ans1;
else //cout << ans2 << endl;
ans = ans2;
break;
}
} printf("%d\n", ans.length());
cout <<ans <<endl; return ;
} /* 15
37504 79054 80071 95721 135743 164345 189260 190810 191657 196168 200000 200000 190810 190018 185437 */
E. Minimum Array
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int a[maxn], c[maxn]; int main() {
multiset<int> s;
scanf("%d", &N);
for(int i = ; i <= N; i ++)
scanf("%d", &a[i]);
for(int i = ; i <= N; i ++) {
int x;
scanf("%d", &x);
s.insert(x);
}
for(int i = ; i <= N; i ++) {
int now = N - a[i] % N;
multiset <int>::iterator it = s.lower_bound(now);
if(it == s.end()) it = s.begin();
c[i] = (a[i] + (*it)) % N;
s.erase(it);
} for(int i = ; i <= N; i ++)
printf("%d%s", c[i], i != N ? " " : "\n"); return ;
}
省赛之后脑子一点都不 丝滑? 暴躁 coder 在线可爱
CodeForces Round #555 Div.3的更多相关文章
- 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...
- Codeforces Round #555 (Div. 3) AB
A: http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...
- Codeforces Round #555 (Div. 3) E. Minimum Array
题意:b数组可以自由排序,c[i]=(a[i]+b[i])%n. 题目中要求c数组的字典序是最小的.那么我们需要尽量满足前面的c[i],才能使字典序最小. 我们知道a[i]和b[i]都是[0,n-1] ...
- Codeforces Round #555 (Div. 3)[1157]题解
不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...
- Codeforces Round #555 (Div. 3) c2 d e f
c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...
- Codeforces Round #555 (Div. 3) D. N Problems During K Days 【数学思维】
一 题面 D. N Problems During K Days 二 分析 对于这题,刚开始我就是陷入了对公式的执着,企图用公式直接确定第一个数,然后试着去找序列.经过思考和手动模拟后发现是很难保证正 ...
- Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version)【模拟】
一 题面 C2. Increasing Subsequence (hard version) 二 分析 需要思考清楚再写的一个题目,不能一看题目就上手,容易写错. 分以下几种情况: 1 左右两端数都小 ...
- Codeforces Round #555 (Div. 3) E. Minimum Array 【数据结构 + 贪心】
一 题面 E. Minimum Array 二 分析 注意前提条件:$0 \le a_{i} \lt n$ 并且 $0 \le b_{i} \lt n$.那么,我们可以在$a_{i}$中任取一个数 ...
- Codeforces Round #555 (Div. 3) A B C1(很水的题目)
A. Reachable Numbers 题意:设f(x)为 x+1 这个数去掉后缀0的数,现在给出n,问经过无数次这种变换后,最多能得到多少个不同的数. 代码 #include<cstdio& ...
随机推荐
- java~google样式检查和命名规范
对于代码的样式和各种元素的命名都是我们架构师需要考虑的,目前在java世界里,比较流行使用java的规范,包括了代码样式检查. 代码样式检查插件 样式文件xml google命名规范 一 代码样式检查 ...
- Spring Boot系列(一) Spring Boot准备知识
本文是学习 Spring Boot 的一些准备知识. Spring Web MVC Spring Web MVC 的两个Context 如下图所示, 基于 Servlet 的 Spring Web M ...
- RDIFramework.NET V3.3 WinForm版新增日程管理功能模块
功能描述 日程管理基于月.周.日的日历视图,把安排到每一天的具体时间点,让每一天的时间都充分利用:甚至您也可以把个人非工作事项也安排进来,完全是属于自己的全时间管理.就是将每天的工作和事务安排在日期中 ...
- 【我们一起写框架】MVVM的WPF框架(一)—序篇
前言 我想,有一部分程序员应该是在二三线城市的,虽然不知道占比,但想来应该不在少数. 我是这部分人群中的一份子. 我们这群人,面对的客户,大多是国内中小企业,或者政府的小部门.这类客户的特点是,资金有 ...
- C#语法——反射,架构师的入门基础。
前言 编程其实就是写代码,而写代码目的就是实现业务,所以,语法和框架也是为了实现业务而存在的.因此,不管多么高大上的目标,实质上都是业务. 所以,我认为不要把写代码上升到科学的高度.上升到艺术就可以了 ...
- Linux 命令行
Linux 命令笔记 一.目录/文件 1.1 目录文件日常操作 . -> 当前目录 .. -> 上一级目录 .file/.dir -> 隐藏文件/文件夹 [ls] 查看指定目录文件 ...
- 使用 pm2 守护你的 .NET Core 应用程序
一.守护进程的前世今生 守护进程,英文名:"daemon",也有守护神的意思.守护进程是一个在后台运行并且不受任何终端控制的进程,不会随着会话结束而退出.诸如 mysql.apac ...
- IIS安装以及发布
控制面板-所有控制面板项-程序和功能-打开或关闭windows功能-Internet 信息服务,里面全部打钩点击确实.安装完成. 控制面板-管理工具-Internet 信息服务管理器-双击打开 ...
- Java 处理 multipart/mixed 请求
一.multipart/mixed 请求 multipart/mixed 和 multipart/form-date 都是多文件上传的格式.区别在于,multipart/form-data 是一种 ...
- Django学习之七:Django 中间件
目录 Django 中间件 自定义中间件 - - - 大体两种方式 将中间件移除 实例 中间件加载源码阅读 总结 Django 中间件 Tips: 更新日志: 2019.01.31 更新django中 ...