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(很水的题目)的更多相关文章

  1. 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  ...

  2. Codeforces Round #555 (Div. 3) 解题报告

    A.Reachable Numbers 题意: 给定操作f(x):将x加1,删去得到的数的所有末尾0,如f(10099)=10099+1=10100→1010→101.现在给定一个数n,对n进行无限次 ...

  3. 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 ...

  4. Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题

    A. Link/Cut Tree 题目连接: http://www.codeforces.com/contest/614/problem/A Description Programmer Rostis ...

  5. Codeforces Round #555 (Div. 3) C1,C2【补题】

    D1:思路:L,R指针移动,每次选最小的即可. #include<bits/stdc++.h> using namespace std; #define int long long #de ...

  6. 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution

    对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...

  7. CodeForces Round #555 Div.3

    A. Reachable Numbers 代码: #include <bits/stdc++.h> using namespace std; ; int N; set<int> ...

  8. Codeforces Round #555 (Div. 3) AB

    A:    http://codeforces.com/contest/1157/problem/A 题意:每次加到10的整数倍之后,去掉后面的0,问最多有多少种可能. #include <io ...

  9. Codeforces Round #555 (Div. 3)[1157]题解

    不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...

随机推荐

  1. Java 设计模式系列(十五)观察者模式(Observer)

    Java 设计模式系列(十五)观察者模式(Observer) Java 设计模式系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Java ...

  2. Basic4android v3.50 发布

    这次发布的主要是debug 的增强.说实话,在这一方面B4a 比delphi做的要好.希望delphi 在新的版本里面 能进一步加强. I'm happy to release Basic4andro ...

  3. python decimal和fractions模块

    1.简介 默认,浮点数学缺乏精确性 decimal 模块提供了一个 Decimal 数据类型用于浮点数计算.相比内置的二进制浮点数实现 float这个类型有助于金融应用和其它需要精确十进制表达的场合, ...

  4. jar包制作一个可执行文件

    1.在桌面新建一个txt文件,然后修改为.bat后缀的文件,例如: 文件命名为:Editfact.bat 2.对文件内容进行编写,如下: %此处为bat文件盘符% c: %此处为jar包位置% cd ...

  5. .NET基础 (20).NET中的数据库开发

    ADO NET和数据库程序基础1 什么是关系型数据库2 如何通过SQL语句来实现行列转换3 ADO NET支持哪几种数据源 ADO NET和数据库的连接1 请简要叙述数据库连接池的机制2 如何提高连接 ...

  6. Ansible运维自动化工具

    1>Ansible 1>ansible简介 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabri ...

  7. mysql my.cnf优化

    [mysqld] lower_case_table_names = 1sql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION skip_name_r ...

  8. Mysql部署

    1. 下载 Mysql 版本为: mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz (注意:下载二进制文件)  存放位置: /usr/local 2. 检查机器上 ...

  9. android AlertDialog.Builder(Context context)换行

    今天无意中发现AlertDialog的 setMessage(String)的换行问题,很多人都说\n可以,不过的却原来就在java里面写好的是可以换行 ,但是如果这个string是在网页或者是其地方 ...

  10. 对SIP摘要认证方案的理解

    一.口令认证常见机制 基于口令认证的系统一般有以下几种口令验证方式: 1.客户端以明文形式将用户名密码通过网络发送到服务器,服务器与已经保存在服务端的用户名密码进行比较,一致则通过验证: HTTP基本 ...