Codeforces Round #555 (Div. 3) A B C1(很水的题目)
A. Reachable Numbers
题意:设f(x)为 x+1 这个数去掉后缀0的数,现在给出n,问经过无数次这种变换后,最多能得到多少个不同的数。
代码
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
int sum=;
map<int,bool>mp;
int f(int x)
{
if(mp[x]==true)
{
return ;
}
//cout<<sum<<endl;
sum++;
mp[x]=true;
//cout<<x<<" "<<mp[x]<<endl;
x++;
while(x%==)
{
x/=;
}
return f(x);
}
int main()
{
int n;
cin>>n;
f(n);
cout<<sum<<endl;
return ;
}
B. Long Number
题意:给一个长度为n的字符串,给出 f 数组表示你可以把字符 x 变成对应的 f (x),你只能修改一段连续的子串,求修改后字典序最大的字符串。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
map<char,char>mp;
int main()
{
int n;
cin>>n;
string str;
cin>>str;
char c[];
for(int t=;t<=;t++)
{
char ss=''+t;
cin>>c;
mp[ss]=c[];
}
int flag=;
for(int t=;t<n;t++)
{
if(mp[str[t]]>str[t])
{
str[t]=mp[str[t]];
flag=;
}
else if(flag==&&mp[str[t]]<str[t])
{
break;
}
} cout<<str<<endl;
return ;
}
C1. Increasing Subsequence (easy version)
题意:给一个长度为 n 的数组,每个数不一样,每次你可以从坐边界或者右边界取一个数,要求每一次取的数都要比上一次取得数要大,求最多可以取多少个数。
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
vector<int>vec;
int main()
{
int n;
cin>>n;
int x;
for(int t=;t<n;t++)
{
scanf("%d",&x);
vec.push_back(x);
}
vector<int>::iterator it1=vec.begin(),it2=vec.end()-;
vector<char>v;
int xx=;
for(int t=;t<n;t++)
{
if(*it2>xx||*it1>xx)
{
if(*it2<*it1&&*it2>xx&&*it1>xx)
{
xx=*it2;
v.push_back('R');
it2--;
}
else if(*it1<*it2&&*it2>xx&&*it1>xx)
{
xx=*it1;
v.push_back('L');
it1++;
}
else if(*it2>xx)
{
xx=*it2;
v.push_back('R');
it2--;
}
else if(*it1>xx)
{
xx=*it1;
v.push_back('L');
it1++;
}
// cout<<xx<<endl;
}
}
cout<<v.size()<<endl;
vector<char>::iterator it=v.begin();
for(it=v.begin();it!=v.end();it++)
{
cout<<*it;
}
return ;
}
Codeforces Round #555 (Div. 3) A B C1(很水的题目)的更多相关文章
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #555 (Div. 3) 解题报告
A.Reachable Numbers 题意: 给定操作f(x):将x加1,删去得到的数的所有末尾0,如f(10099)=10099+1=10100→1010→101.现在给定一个数n,对n进行无限次 ...
- Codeforces Round #396 (Div. 2) A B C D 水 trick dp 并查集
A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
A. Link/Cut Tree 题目连接: http://www.codeforces.com/contest/614/problem/A Description Programmer Rostis ...
- Codeforces Round #555 (Div. 3) C1,C2【补题】
D1:思路:L,R指针移动,每次选最小的即可. #include<bits/stdc++.h> using namespace std; #define int long long #de ...
- 老年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
A. Reachable Numbers 代码: #include <bits/stdc++.h> using namespace std; ; int N; set<int> ...
- Codeforces Round #555 (Div. 3) AB
A: http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...
- Codeforces Round #555 (Div. 3)[1157]题解
不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...
随机推荐
- 第十届国际用户体验创新大赛携Mockplus走进校园
今日立夏,万木并秀,生生不息,第十届国际用户体验创新大赛即将拉开序幕.5月5日下午,一场用户体验设计经验分享活动携带众多嘉宾降临成都理工大学,为西南赛区首站赛事宣讲. 本次宣讲活动邀请了华为技术有限公 ...
- idea中代码补全
在IDEA中,默认的代码自动提示不够智能,现在配置成更加智能的方式. File-Settings-Editor-General-Code Completion中 把最上面的大小写敏感度改成none,下 ...
- UVa 818Cutting Chains (暴力dfs+位运算+二进制法)
题意:有 n 个圆环,其中有一些已经扣在一起了,现在要打开尽量少的环,使所有的环可以组成一条链. 析:刚开始看的时候,确实是不会啊....现在有点思路,但是还是差一点,方法也不够好,最后还是参考了网上 ...
- POJ2031 Building a Space Station 2017-04-13 11:38 48人阅读 评论(0) 收藏
Building a Space Station Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8572 Accepte ...
- 团体程序设计天梯赛L1-019 谁先倒 2017-03-22 17:35 33人阅读 评论(0) 收藏
L1-019. 谁先倒 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 划拳是古老中国酒文化的一个有趣的组成部分.酒桌上两人划拳 ...
- 如何注册GitHub
一.个人介绍 姓名:张志龙 学号:1413042026 班级:网工141 爱好:宅物 能力:c++编程 二.注册 注册GitHub其实很简单 首先我们要做的是打开官网 www.github.com(如 ...
- 支付宝PC网站接口对接
PC网站支付接口,请参考支付宝官方文档:https://b.alipay.com/signing/productSet.htm?navKey=all 1.需要提供签约账号.商户密钥 2.代码实现: 支 ...
- Git 安装配置,key导入
系统 Centos 6.5 安装git 命令 yum install git 配置git用户名 git config --global user.name "yangchengguo&q ...
- 关于My Sql update语句不能用子查询的解决办法
在使用My Sql数据库语法操作update时,第一时间想到的是一下写法: UPDATE purchase_request_detail SET convert_to_voucher_id=, con ...
- 简易网页 html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...