Heshen was an official of the Qing dynasty. He made a fortune which could be comparable to a whole country's wealth by corruption. So he was known as the most corrupt official in Chinese history. But Emperor Qianlong liked, or even loved him so much that was not punished during Qianlong's regime even everybody knew he was totally corrupted.

After Qianlong quit his job, his son Jiaqing took the throne. The new Emperor hated Heshen very much, so he threw Heshen into jail and awarded him death immediately after Qianlong died. Of course Jiaqing would not forget to raid Heshen's house for money --- that was the story of "Heshen fell, Jiaqing full."

Jiaqing's man got a notebook from Heshen's home which was obviously an account book.But the text of the book was written in English! Jiaqing thought all numbers in that account book should stand for money. Please find out all numbers for Jiaqing.

The text of the account book consists only lower case letters, spaces, and digits
('0' - '9'). One or several consecutive digits form a number. But Jiaqing only cared about the ACTUAL numbers among all numbers. Only if a number DOESN'T satisfy any of the conditions below, it is an ACTUAL number:

1) The character to the left of the number is a lower case letter, for example: a123

2) The character to the right of the number is a lower case letter, for example: 123b

3) The number has one or more extra leading zeros, such as 01 , 0012….

Please note that if the last character of a line is a digit, and the first character of the next line is also a digit, those two digits are considered consecutive.

Input

There are no more than 200 lines. The length of each line is no more than 1000 characters.

And it is guaranteed that every number's length is no more than 18.

There may be spaces at the end of a line, and those spaces matter.

No blank lines in the input. A line consisting of only spaces is not a blank line.

Output

Print all ACTUAL numbers in a single line in the original order.
Then, count the number of ACTUAL numbers of each line, and print them. A number X only belongs to the line which contains the first digit of X.

Sample Input

a19 01 17b
12 bdc 13
23 14 344 bc

Sample Output

12 1323 14 344
0
2
2 题意:
给你多行只含有数字,空格,小写字母的字符串。
让你从中输出她们想要的数字,并记录每一行有多少个他们想要的数字。
他们想要的数字有以下限制:
第一个字符不能是字母。
最后一个字符不能是字母。
不能有前导0. 题目有以下坑点(巨坑,毒瘤):
1,
123edwe124 是一个有效的数字 它是 123124 (心情:出题人你认真的?)
2:最后一行的尾部没有回车 ,处理的时候要额外注意
3:如果一行的最后一个字符是数字,下一行的第一个字符是数字,那么下一行的头部数字是连着上一行的,(奇葩的处理)。
4. 只有一个0, 不是前导0,而是一个有效数字0. 解决坑点就按照题意模拟实现就好了,细节见代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = ; while (b) {if (b % )ans = ans * a % MOD; a = a * a % MOD; b /= ;} return ans;}
inline void getInt(int* p);
const int maxn = ;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char s[];
int ans[maxn];
bool check(string str)
{
if (str == "")
{
return ;
}
int len = str.length();
if (str[] >= 'a' && str[] <= 'z')
{
return ;
} else if (str[len - ] >= 'a' && str[len - ] <= 'z')
{
return ;
} else {
if (len == )
{
return ;
} else
{
if (str[] == '')
{
return ;
} else
{
return ;
}
}
}
}
int main()
{
// freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
int n = ;
char x;
while (~scanf("%c", &x))
{
s[n++] = x;
}
string temp = "";
int cnt = ;
std::vector<string> v;
int huiche = ;
rep(i, , n)
{
if (s[i] == ' ')
{
if (check(temp))
{
// db(temp);
int num = temp.length();
string str = "";
rep(j, , num)
{
if (temp[j] >= '' && temp[j] <= '')
{
str += temp[j];
}
}
v.push_back(str);
ans[cnt]++;
// cout<<cnt<<" "<<str<<" "<<huiche<<endl;
}
cnt += huiche;
huiche = ;
temp = "";
continue;
} else if (s[i] == '\n')
{
huiche++;
int num = temp.length();
if (s[i - ] >= '' && s[i - ] <= '')
{
if (s[i + ] >= '' && s[i + ] <= '')
{
int j = i + ;
while (s[j] != ' ' && s[j] != '\n')
{
temp += s[j++];
}
i = j - ;
} else
{
if (check(temp))
{
// db(temp);
int num = temp.length();
string str = "";
rep(j, , num)
{
if (temp[j] >= '' && temp[j] <= '')
{
str += temp[j];
}
}
v.push_back(str);
ans[cnt]++;
// cout<<cnt<<" "<<str<<" "<<huiche<<endl; }
cnt += huiche;
huiche = ;
temp = "";
continue;
}
} else
{
if (check(temp))
{
// db(temp);
int num = temp.length();
string str = "";
rep(j, , num)
{
if (temp[j] >= '' && temp[j] <= '')
{
str += temp[j];
}
}
v.push_back(str);
ans[cnt]++;
// cout<<cnt<<" "<<str<<" "<<huiche<<endl; }
cnt += huiche;
huiche = ;
temp = "";
continue;
}
} else
{
temp += s[i];
}
}
if (check(temp))
{
// db(temp);
int num = temp.length();
string str = "";
rep(j, , num)
{
if (temp[j] >= '' && temp[j] <= '')
{
str += temp[j];
}
}
v.push_back(str);
ans[cnt]++;
// cout<<cnt<<" "<<str<<" "<<huiche<<endl;
}
for (int i = ; i < sz(v); ++i)
{
cout << v[i];
if (i != sz(v) - )
{
cout << " ";
}
}
cout << endl;
repd(i, , cnt)
{
// cout<<i<<" "<<ans[i]<<endl;
cout << ans[i] << endl;
} return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}
												

Heshen's Account Book HihoCoder - 1871 2018北京区域赛B题(字符串处理)的更多相关文章

  1. B - Heshen's Account Book HihoCoder - 1871

    题目链接:https://hihocoder.com/problemset/problem/1871 思路:满满的细节满满的坑,尤其是 123df123 居然也要算成123123 的时候真是惊呆了,我 ...

  2. 2018 北京区域赛 I - Palindromes (找规律)

    题目 HihoCoder - 1878 题目大意 给出k,让求出第k个回文数(k的“长度”不超过1e5) 题解 之前做过类似的题,是统计各阶段的数找到第K个回文数,但这里K太大,需要寻找新的方法. 打 ...

  3. hihocoder 1236(2015北京网络赛 J题) 分块bitset乱搞题

    题目大意: 每个人有五门课成绩,初始给定一部分学生的成绩,然后每次询问给出一个学生的成绩,希望知道在给定的一堆学生的成绩比这个学生每门都低或者相等的人数 因为强行要求在线查询,所以题目要求,每次当前给 ...

  4. ACM-ICPC 2018北京网络赛-A题 Saving Tang Monk II-优先队列

    做法:优先队列模板题,按步数从小到大为优先级,PASS掉曾经以相同氧气瓶走过的地方就好了 题目1 : Saving Tang Monk II 时间限制:1000ms 单点时限:1000ms 内存限制: ...

  5. Hihocoder 1634 Puzzle Game(2017 ACM-ICPC 北京区域赛 H题,枚举 + 最大子矩阵变形)

    题目链接  2017 Beijing Problem H 题意  给定一个$n * m$的矩阵,现在可以把矩阵中的任意一个数换成$p$,求替换之后最大子矩阵的最小值. 首先想一想暴力的方法,枚举矩阵中 ...

  6. HihoCoder 1629 Graph (2017 ACM-ICPC 北京区域赛 C题,回滚莫队 + 启发式合并 + 可撤销并查集)

    题目链接  2017 ACM-ICPC Beijing Regional Contest Problem C 题意  给定一个$n$个点$m$条边的无向图.现在有$q$个询问,每次询问格式为$[l, ...

  7. 北京区域赛I题,Uva7676,A Boring Problem,前缀和差分

    转载自https://blog.csdn.net/weixin_37517391/article/details/83821752 题解 其实这题不难,只要想到了前缀和差分就基本OK了. 我们要求的是 ...

  8. 2018南京区域赛G题 Pyramid——找规律&&递推

    先手动推出前10项,再上BM板子求出递推式 $A_n = 5A_{n-1} - 10A_{n-2} + 10A_{n-3} - 5A_{n-4} + A_{n-5}$,根据特征根理论可求出特征方程 $ ...

  9. 2018南京区域赛K题 Kangaroo Puzzle——随机&&乱搞

    题意 在 n * m 的平面上有若干个袋鼠和墙(1为袋鼠,0为墙),每次可以把所有袋鼠整体往一个方向移动一步(不能走出边界和不能走到墙),为在不超过50000步的情况下能否把全部袋鼠聚集在同一个位置. ...

随机推荐

  1. Python学习之==>面向对象编程(二)

    一.类的特殊成员 我们在Python学习之==>面向对象编程(一)中已经介绍过了构造方法和析构方法,构造方法是在实例化时自动执行的方法,而析构方法是在实例被销毁的时候被执行,Python类成员中 ...

  2. SAS数据挖掘实战篇【六】

    SAS数据挖掘实战篇[六] 6.3  决策树 决策树主要用来描述将数据划分为不同组的规则.第一条规则首先将整个数据集划分为不同大小的 子集,然后将另外的规则应用在子数据集中,数据集不同相应的规则也不同 ...

  3. Delphi中的Free和Nil和freeandnil函数

    Delphi中的Free和Nil 在Delphi中释放对象资源时一般用Obj.Free(Obj为一个实例名),不过程Delphi中还有一个FreeAndNil(对象名)函数,那么用哪个好呢?Free和 ...

  4. java:easyui(jQueryEasyUI,分页)

    1.介绍: jQuery EasyUI是一组基于jQuery的UI插件集合体,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面.开发者不需要编写复杂的ja ...

  5. Spring 中如何自动创建代理(spring中的三种自动代理创建器)

    Spring 提供了自动代理机制,可以让容器自动生成代理,从而把开发人员从繁琐的配置中解脱出来 . 具体是使用 BeanPostProcessor 来实现这项功能. 这三种自动代理创建器 为:Bean ...

  6. shadow使用方法

    cd shadow/resource/examples for d in shadow.data/host/*client*: do grep "transfer-complete" ...

  7. SpringCloud 和 Dubbo 有哪些区别?

    首先,他们都是分布式管理框架.    dubbo 是二进制传输,占用带宽会少一点.SpringCloud是http 传输,带宽会多一点,同时使用http协议一般会使用JSON报文,消耗会更大.    ...

  8. java.time包常用类API学习记录

    Java8出来已那么多年了,java.time包之前一直没有使用过,最近正好有用到,在此做个记录. 上图列出了java.time包下的类,接下来我们详细看下其中每个类的用法. Clock:获取到当前时 ...

  9. 洛谷 P1809 过河问题 题解

    题面 这道题是一道贪心+DP的好题: 首先排序是一定要干的事情. 然后我们分情况处理: 1.如果剩一个人,让最小的回来接他 2.如果剩两个人,让最小的回来接,剩下的那两个人(即最大的两个人)过去,让次 ...

  10. Kali安装在U盘+使用aircrack-ng套件

    因为: Kali Linux 自带aircrack-ng 虚拟机VMware不能用笔记本内置网卡,需要另外买一个无线网卡,然而并不想买 不想给笔记本重装Kali Linux系统 有闲置的32GU盘 所 ...