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& ...
随机推荐
- 【Android Studio安装部署系列】十一、Android studio获取数字签名信息
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 下面介绍下调试版本和发布版本获取数字签名的方法,通过以下方法可以获取到SHA1和MD5. 一般在使用分享功能,在第三方平台中创建应用 ...
- java~api返回值的标准化
api返回值的标准化 例如 {"status":200,"message":"操作成功","data":"{\ ...
- cocos creator主程入门教程(九)—— 瓦片地图
五邑隐侠,本名关健昌,10年游戏生涯,现隐居五邑.本系列文章以TypeScript为介绍语言. 这一篇介绍瓦片地图,在开发模拟经营类游戏.SLG类游戏.RPG游戏,都会使用到瓦片地图.瓦片地图地面是通 ...
- 成为一名Java架构师的必修课
一.热门框架源码学习 设计模式篇 Spring5源码解读篇 Mybatis篇 SpringBoot2篇 二. 微服务架构 架构设计篇 BAT互联网架构这些年的演进分析 国内外常见分布式系统架构状况介绍 ...
- Dynamics 365中的批量删除作业执行频率可以高于每天一次吗?
微软动态CRM专家罗勇 ,回复317或者20190314可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 我先来做一个例子,登 ...
- 我的世界 ParaCraft 结合开源地图 OpenStreetMap 生成3D校园的方法简介
我的世界ParaCraft结合开源地图OpenStreetMap生成3D校园的方法简介 版本1.0 日期2019.2.3 作者Ray (82735589@qq.com) www.TimeGIS.com ...
- Java中的守护线程
守护线程的概念 在java中有两种线程,守护线程和非守护线程,其两者并没有本质的区别,唯一的区别就是当前的用户线程退出的时候,若只存在唯一的A线程,若A线程为守护线程,那么JVM将会直接退出,否则JV ...
- js饼状图(带百分比)功能实现,新人必懂
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- SQLServer删除登录帐户
删除登陆账户注意事项 不能删除正在登录的登录名. 也不能删除拥有任何安全对象.服务器级对象或 SQL Server 代理作业的登录名. 可以删除数据库用户映射到的登录名,但是这会创建孤立用户. 有关详 ...
- Thymeleaf 的 onclick
th:onclick="'javascript:openBox(\''+${curCabNo}+'\',\''+${box.no}+'\')'" 真的难受 ,有没有好办法!!!!