POJ 3602 Typographical Ligatures
【题意简述】:题意就是输入一串字符串,问我们有多少种不同的字符,也就是说出现过一次的字符,下次就不记到种数中了,特别的有 ff, fi ,fl ,ffi ,ffl,'',``, 这几个每一个算是一种。
【分析】:经过题意简述,便好攻克了。
代码:
// 196K 0Ms
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std; char s[1000];
int count1[1000];
int ff[7];
int len; void solve()
{
int ans = 0;
memset(count1,0,sizeof(count1));
memset(ff,0,sizeof(ff));
for(int i = 0;i<len;i++)
{
if(s[i] == 'f')
{
if(s[i+1] == 'f' && (s[i+2] == 'i' || s[i+2]=='l'))
{
if(s[i+2] == 'i')
ff[0]=1;
if(s[i+2] == 'l')
ff[1]=1;
i+=2;
}
else if(s[i+1]=='f'||s[i+1]=='i'||s[i+1]=='l')
{
if(s[i+1]=='f')
ff[2]=1;
if(s[i+1]=='i')
ff[3]=1;
if(s[i+1]=='l')
ff[4]=1;
i++;
}
else
count1[s[i]]=1;
}
else if(s[i]=='`'&&s[i+1]=='`')
{
ff[5]=1;
i++;
}
else if(s[i]=='\''&&s[i+1]=='\'')
{
ff[6]=1;
i++;
}
else
count1[s[i]]=1;
}
for(int i = 0;i<=256;i++)
if(count1[i]) ans++;
for(int i = 0;i<7;i++)
if(ff[i]) ans++;
cout<<ans<<endl;
} int main()
{
char c;
len = 0;
while(cin>>c)
{
if(c == EOF) break; if(c == ' '||c == '\n') continue;
s[len++] = c;
}
solve();
return 0;
}
POJ 3602 Typographical Ligatures的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- iOS 执行ScrollView在空白空间-解
iOS7 中间UIViewControllers配置automaticallyAdjustsScrollViewInsets.假设YES.scrollview它会根据status bar, navig ...
- angular cors跨域资源共享设置 和formdata设定
非常easy,下来容易找到: <pre name="code" class="javascript">.config(['$routeProvide ...
- linux内核包转发过程(三)NIC帧接收分析
[版权声明:转载请保留源:blog.csdn.net/gentleliu.邮箱:shallnew*163.com] 每一个cpu都有队列来处理接收到的帧.都有其数据结构来处理入口和出口流量,因此.不同 ...
- zju2676 Network Wars 分数规划+网络流
题意:给定无向图,每条边有权值,求该图的一个割集,是的该割集的平均边权最小 Amber的<最小割模型在信息学竞赛中的应用>中讲的很清楚了. 二分答案k,对每条边进行重新赋值为原边权-k,求 ...
- Matlab.NET混合编程技巧之——直接调用Matlab内置函数(附源码)
原文:[原创]Matlab.NET混合编程技巧之--直接调用Matlab内置函数(附源码) 在我的上一篇文章[原创]Matlab.NET混编技巧之——找出Matlab内置函数中,已经大概的介绍了mat ...
- HDU 4349 Xiao Ming's Hope
非常无语的一个题. 反正我后来看题解全然不是一个道上的. 要用什么组合数学的lucas定理. 表示自己就推了前面几个数然后找找规律. C(n, m) 就是 组合n取m: (m!(n-m!)/n!) 假 ...
- 一步一步的理解C++STL迭代器
一步一步的理解C++STL迭代器 "指针"对全部C/C++的程序猿来说,一点都不陌生. 在接触到C语言中的malloc函数和C++中的new函数后.我们也知道这两个函数返回的都是一 ...
- RTP 记录 log 该机制
我们 RCV 在这里,经常跑concurrent request RTP: Receiving Transaction Processor, 它主要是用来处理 RCV_TRANSACTIONS_INT ...
- NSOJ Minimum Transport Cost
These are N cities in Spring country. Between each pair of cities there may be one transportation tr ...
- CSS定位与层叠
position:static(静态定位) 当position属性定义为static时,可以将元素定义为静态位置,所谓静态位置就是各个元素在HTML文档流中应有的位置 podisition定位 ...