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获得各种文档文件夹路径的方法
iphone沙箱模型的有四个目录,各自是什么,永久数据存储一般放在什么位置.得到模拟器的路径的简单方式是什么. documents,tmp.app,Library. (NSHomeDirectory( ...
- Android Studio简单设置(转)
Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings --> Appearance --> Th ...
- android 内存泄漏分析技巧
java虚拟机执行一般都有一个内存界限,超过这个界限,就会报outofmemory.这个时候一般都是存在内存泄漏.解决内存泄漏问题,窃以为分为两个步骤:分析应用程序是否真的有内存泄漏,找到内存泄漏的地 ...
- Android清除缓存功能来实现
我们都知道在Android的设置->应用程序中能够查看应用程序的相关信息,当中有一个功能是清除缓存. 如图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZ ...
- 【Linux】CentOS系统
版本号:CentOS release 5.7 1)查看系统版本号 cat /etc/readhat-release 2)安装软件 wget 资源链接 make make install 在线安装: ...
- 使用 CodeIgniter 框架快速开发 PHP 应用(二)
原文:使用 CodeIgniter 框架快速开发 PHP 应用(二) 二分钟: 建立一个 CodeIgniter 网站用CI建一个网站很容易. 这一章很短,解释了用CI制作网站时发生了些什么,哪些文件 ...
- HTML文档中应用css样式的方法总结
在HTML文档中应用css样式大致有三种方法:1.link标签链接外部样式表:2.使用style元素包含样式表:3.使用style属性,即内联样式 一.link标签链接外部样式表 先看一条较为标准的l ...
- C# 你不能调用的问题剪贴板线程
最近在做一个项目,需要使用线程,并使用剪贴板,头发得到较少的数据在剪贴板上后,现在的孩子线程创建一个子线程,我特别困惑,上网查资料.最后,得到最终的.下面的例子现在将概括解: 第一步: public ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
- Android dumpsys命令的使用
Android提供的dumpsys工具能够用于查看手机中的应用程序和系统服务信息与状态,手机连接电脑后能够直接命令行运行adb shell dumpsys 查看全部支持的Service可是这样输出的太 ...