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. nvidia显卡驱动

    http://blog.csdn.net/Monica__2012/article/details/75577522 $nvidia-smi

  2. FW:考查嵌入式C开发人员的最好的16道题(转)

    考查一个初级嵌入式系统开发人员的C基本功,附有答案题目由资深嵌入式系统专家拟定, 目的是考查入门级的嵌入式软件开发人员 Gavin Shaw提供详细解答. 编者按:非常基本关于C语言的问题,一个信息类 ...

  3. 数据挖掘分类算法之决策树(zz)

    决策树(Decision tree) 决策树是以实例为基础的归纳学习算法.     它从一组无次序.无规则的元组中推理出决策树表示形式的分类规则.它采用自顶向下的递归方式,在决策树的内部结点进行属性值 ...

  4. pom.xml的继承、聚合与依赖

    原文地址:https://my.oschina.net/zh119893/blog/232896 6.1     简介 pom.xml文件是Maven进行工作的主要配置文件.在这个文件中我们可以配置M ...

  5. C++ 类 & 对象-C++ 内联函数-C++ this 指针-C++ 类的静态成员

    C++ 内联函数 C++ 内联函数是通常与类一起使用.如果一个函数是内联的,那么在编译时,编译器会把该函数的代码副本放置在每个调用该函数的地方. 对内联函数进行任何修改,都需要重新编译函数的所有客户端 ...

  6. Restful风格wcf调用2——增删改查

    写在前面 上篇文章介绍如何将wcf项目,修改成restful风格的接口,并在上面提供了查询的功能,上篇文章中也感谢园友在评论中的提的建议,自己也思考了下,确实是那个道理.在urltemplate中,定 ...

  7. Swift:使用CAShapeLayer打造一个ProgresssBar

    ProgressBar是一个很小却在很多地方都会用到的东西.也许是网络连接,也许APP本身有很多东西需要加载的.默认的只有一个旋转的菊花,对于打造一款个性的APP这显然是不够的.这里就使用CAShap ...

  8. 为iOS项目添加Daily Build

    很多人在说到Daily Build的时候总是喜欢背书.背书就背书吧,总比混迹软件行业连书都没看过的强.很久以前遇到一个奇葩.每次到代码提交测的通知就着急忙慌的催促组员赶紧干活,开始严重加班,晚饭都不吃 ...

  9. Linux 基础教程 40-df和du命令

    df     df用于显示文件系统的整体磁盘使用量. 基本用法 df [选项] [目录/文件] 其常用选项如下所示: 选项 说明 -a, --all 显示所有文件系统,包括/proc等虚拟文件系统 - ...

  10. (并查集 带关系)Find them, Catch them -- poj -- 1703

    链接: http://poj.org/problem?id=1703 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3676 ...