洛谷试炼场 - 关卡1-5 - 简单字符串 - (Done)
#include<bits/stdc++.h>
using namespace std;
string s;
char e[]={'','','','','','','','','','','X'};
int main()
{
cin>>s;
int res=;
for(int p=,c=;p<=;p++)
if(s[p]!='-') res+=(s[p]-'')*(++c), res%=;
if(e[res]==s[]) cout<<"Right"<<endl;
else cout<<(s.substr(,)+e[res])<<endl;
}
P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He…
#include<bits/stdc++.h>
using namespace std;
int a,b;
string s;
int main()
{
cin>>s;
a=;
for(uint32_t i=;i<s.size();i++) a*=(s[i]-'A'+), a%=;
cin>>s;
b=;
for(uint32_t i=;i<s.size();i++) b*=(s[i]-'A'+), b%=;
if(a==b) cout<<"GO"<<endl;
else cout<<"STAY"<<endl;
}
P1308 统计单词数
(我觉得这题输入输出有毛病……跳过吧)
#include<bits/stdc++.h>
using namespace std;
string s;
void rev(string& s)
{
int i=, j=s.size()-;
while(i<j) swap(s[i++],s[j--]);
}
void del(bool f,string& s)
{
if(f) //后导零
{
while(s.size() && s.back()=='') s.erase(s.size()-,);
if(s.empty()) s="";
}
else //前导零
{
while(s.size() && s[]=='') s.erase(,);
if(s.empty()) s="";
}
}
int main()
{
cin>>s;
int p; string a,b;
if((p=s.find('.'))!=string::npos) //小数
{
a=s.substr(,p), b=s.substr(p+);
rev(a), rev(b);
del(,a), del(,b);
s=a+'.'+b;
}
else if((p=s.find('/'))!=string::npos) //分数
{
a=s.substr(,p), b=s.substr(p+);
rev(a), rev(b);
del(,a), del(,b);
s=a+'/'+b;
}
else if((p=s.find('%'))!=string::npos) //百分数
{
a=s.substr(,p);
rev(a), del(,a);
s=a+'%';
}
else rev(s), del(,s); //整数
cout<<s<<endl;
}
#include<bits/stdc++.h>
using namespace std;
string s[];
int cnt[];
int main()
{
for(int i=;i<=;i++)
{
getline(cin,s[i]);
for(auto x:s[i]) if(isupper(x)) cnt[x-'A']++;
}
int mx=; for(int i=;i<;i++) mx=max(mx,cnt[i]);
for(int r=mx;r>=;r--)
{
int lim=; for(int c=;c<;c++) if(cnt[c]>=r) lim=c;
for(int c=;c<=lim;c++)
{
if(c>) printf(" ");
if(cnt[c]>=r) printf("*");
else printf(" ");
}
printf("\n");
}
for(int c=;c<;c++)
{
if(c>) printf(" ");
printf("%c",'A'+c);
}
}
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
cin>>n>>s;
for(auto x:s) cout<<(char)('a'+(x-'a'+n)%);
}
洛谷试炼场 - 关卡1-5 - 简单字符串 - (Done)的更多相关文章
- 洛谷试炼场 - 关卡2-1 - 简单的模拟 - (Done)
最近这段时间感冒外加一些乱七八糟的事情,导致脑子严重僵化……只好刷刷基础(水)题巩固巩固基础(混混题数). 目录 P1003 铺地毯 P1067 多项式输出 P1540 机器翻译 P1056 排座椅 ...
- 洛谷试炼场-简单数学问题-P1403 [AHOI2005]-因数
洛谷试炼场-简单数学问题 P1403 [AHOI2005]约数研究 Description 科学家们在Samuel星球上的探险得到了丰富的能源储备,这使得空间站中大型计算机"Samuel I ...
- 洛谷试炼场-简单数学问题-P1045 麦森数-高精度快速幂
洛谷试炼场-简单数学问题 B--P1045 麦森数 Description 形如2^P−1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果PP是个素数,2^P-1 不一定也是素数.到19 ...
- 洛谷试炼场-简单数学问题-P1088 火星人
洛谷试炼场-简单数学问题 A--P1088 火星人 Description 人类终于登上了火星的土地并且见到了神秘的火星人.人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法 ...
- 洛谷 P4036 [JSOI2008]火星人(splay+字符串hash)
题面 洛谷 题解 首先,我们知道求最长公共前缀可以用二分答案+hash来求 因为有修改操作, 考虑将整个字符串的hash值放入splay中 接着就是splay的基本操作了 Code #include& ...
- 洛谷 P3263 [JLOI2015]有意义的字符串
洛谷 首先,看到\((\frac{(b+\sqrt{d})}{2})^n\),很快能够想到一元二次方程的解\(\frac{-b\pm\sqrt{\Delta}}{2a}\). 所以可以推出,\(\fr ...
- 洛谷P3234 抄卡组 [HNOI2014] 字符串hash
正解:字符串hash 解题报告: 传送门! 字符串hash是字符串匹配中很常见的一个方法,原理也很好懂,这里就不做太多阐述辣有时间放到hash笔记里面去QAQ 题意不说了挺好理解的,自带一句话概括好评 ...
- 洛谷 P1308 统计单词数【字符串+模拟】
P1308 统计单词数 题目描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次数. 现在,请你编程实现这一功能,具体要求是:给定 ...
- 洛谷P3538 [POI2012]OKR-A Horrible Poem [字符串hash]
题目传送门 A Horrible Poem 题目描述 Bytie boy has to learn a fragment of a certain poem by heart. The poem, f ...
随机推荐
- gmock
https://www.cnblogs.com/welkinwalker/archive/2011/11/29/2267225.html http://www.cnblogs.com/jycboy/p ...
- Python的虚拟机安装已经如何配置Scrapy for Mac
时间:2018年2月21日 因为时间问题,以下笔记就粗略记录.仅作为个人笔记为用 安装virtualenv和virtualenvwrapper 如何安装的细节下面这篇也有介绍,包括如何使用切换虚拟机也 ...
- Mybatis判断map参数是否存在
<select id="selectByCondition" parameterType="java.util.HashMap" resultMap=&q ...
- IOS逆向-砸壳笔记
本人ios10.3.1 iphone6越狱机.方案三个. 方案一.dumpdecrypted.dylib 1. ssh到越狱机上,看WeChat可执行文件在哪. # ps aux|grep WeCha ...
- virtualbox安装android6.0并设置分辨率为1920x1080x32
下载安装:https://www.cnblogs.com/wynn0123/p/6288344.html 这里我做的是下载android6.0-64bit,然后文件系统只支持ext4 安装完成之后我的 ...
- mybatis-plus忽略映射字段
mybatis-plus使用对象属性进行SQL操作,经常会出现对象属性非表字段的情况,忽略映射字段使用以下注解: @TableField(exist = false):表示该属性不为数据库表字段,但又 ...
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)
C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- hdoj:2055
#include <iostream> #include <string> using namespace std; bool islower(char ch) { if (c ...
- return在try...except...finally...中的表现
一直以为return就直接退出函数了,最近遇到一情况,在try中return,并没有什么卵用,还是会去执行finally里的内容,导致不能正确返回想要的数据 一直以为return就会跳出函数,发现原来 ...
- tensorflow c/c++库使用方法
tensorflow目前支持最好的语言还是python,但大部分服务都用C++ or Java开发,一般采用动态链接库(.so)方式调用算法,因此tensorflow的c/c++ API还是有必要熟悉 ...