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. [SoapUI] EndPoint不需要在配置文件中设置不同环境的值,SoapUI自带此参数的设置

    在Environments里面设置就好了

  2. Docker 基本原理

    1 什么是Docker? Docker是基于Go语言实现的云开源项目.Docker的主要目标是“Build,Ship and Run Any App,Anywhere”,也就是通过对应用组件的封装.分 ...

  3. Ansible 笔记 (1) - 安装和配置

    本文参考 <Ansible 自动化运维和最佳实践>,这两天刚读这本书,写写总结.主控机环境是 centos 7,被控机均是 centos 6.8 . 确保 python 版本大于 2.6 ...

  4. idea jvm 优化

    修改对应配置文件 64位的是idea64.exe.vmoptions -Xms2048m -Xmx2048m -Xmn1024m -XX:PermSize=512m -XX:MaxPermSize=5 ...

  5. handsontable 概述

    很像excel的jquery插件.关于它的中文资料不多,自己只能看看英文的了.记录如下: developer guide //主要是这八部分数据绑定:renderer, afterchange, se ...

  6. R12 查询EBS用户相关SQL

    --R12查询EBS在线用户SQL SELECT U.USER_NAME,       APP.APPLICATION_SHORT_NAME,       FAT.APPLICATION_NAME,  ...

  7. SqlServer 的一个坑

    以前一直以为sqlserver 在做ddl 操作的时候是锁表的,而oracle 是锁行,感觉oracle 要比sqlserver 先进一些,但是这是我的认识错误.其实sqlserver 也是可以锁行的 ...

  8. Android-无序广播

    在之前的博客,Android-广播概念,中介绍了(广播和广播接收者)可以组件与组件之间进行通讯,有两种类型的广播(无序广播 和 有序广播),这篇博客就来讲解无序广播的代码实现: 无序广播:接收者 同时 ...

  9. Linq使用中的ToList注意事项

    在使用Linq时,如果查询逻辑太复杂,可以拆分为多个Linq查询,下一个Linq在上一个Linq查询的结果上继续操作,这样逻辑清晰,又不会出错.但在使用ToList的时候需要注意,最常见碰到的错误是: ...

  10. eayui js动态加载Datagrid,自适应宽度,高度

    HTML: <div class="easyui-layout" style="min-height:100%;min-width:100%;"> ...