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个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- C++ 内部排序(一)
先讲两个概念,所谓内部排序,指待排序的节点均存储在内存中.所谓排序的稳定性,指排序后,值相等的两个元素原来相对的位置是否发生变化了.举个例子. 待排序列:3(1),1,5,3(2) 稳定排序:1,3 ...
- UVA - 11324 The Largest Clique 强连通缩点+记忆化dp
题目要求一个最大的弱联通图. 首先对于原图进行强连通缩点,得到新图,这个新图呈链状,类似树结构. 对新图进行记忆化dp,求一条权值最长的链,每一个点的权值就是当前强连通分量点的个数. /* Tarja ...
- RS-232协议和RS-485协议
RS232 RS232是一种异步传输标准接口.通常 RS-232 接口以9个引脚 (DB-9) 或是25个引脚 (DB-25) 的型态出现 .RS232最经常使用的连接方式是三根线:一条发送线.一条接 ...
- Controller 里面就只应该存放这些不能复用的代码(转)
MVC 的历史 MVC,全称是 Model View Controller,是模型 (model)-视图 (view)-控制器 (controller) 的缩写.它表示的是一种常见的客户端软件开发框架 ...
- mariadb 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost /]# systemctl stop mariadb.service[root@localhost /]# mysqld_safe --user=mysql --ski ...
- js 通信
js 页面间的通信 看了一下公司原来的代码,原页面ajax post返回一个页面完整的HTML,然后再打开一个新页面并输出ajax返回的所有代码到新页面上,在新页面上以表单提交的形式实现重定向. 任凭 ...
- 蜘蛛牌 (DFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1584 全部状态都判断一遍 代码: #include <stdio.h> #include ...
- Firefox firebug and xpath checker
From http://blog.sina.com.cn/s/blog_5aefba9a0100csy8.html
- "错: void 值不被忽略,因为预期"解决
在C陷阱与缺陷,实现assert什么时候,在这个过程很聪明,化为一个表达式,在当条件为假时就会调用_assert_error报错并终止程序. 刚開始_assert_error 的返回值类型是 void ...
- hdu Word Amalgamation(map)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 找单词 #include <iostream> #include <strin ...