打表格,字符串处理,POJ(2136)】的更多相关文章

题目链接:http://poj.org/problem?id=2136 水题WA了半天,结果是数组开小了. #include <stdio.h> #include <string.h> ]; ]= {}; int main() { ; i<; i++) { gets(s); int len=strlen(s); ; j<len; j++) { if(s[j]>='A'&&s[j]<='Z') num[s[j]-'A']++; } } *][*…
题目链接:http://poj.org/problem?id=2136 题意不难理解,就是输入四行字符串(每行字符总数不超过72个),统计26个英文字母的数目,并按柱状图的形式输出.我的思路就是,先用一维数组total[]统计每个英文字母的个数,接着找出最大的频率,保存在max中:紧接着用一个二维数组word[][](这个比较关键)记录每一个字母在0-max中是否存储数据,有的话则置1,没有则为0.(假如:字母'A'的频率是2,max = 10,那么word[0][0] = 0, word[0]…
Oulipo Problem's Link ---------------------------------------------------------------------------- Mean: 给你一个模式串P和一个母串S,让你统计P串在S串中出现的次数. analyse: 一开始想到的就是使用KMP,就用KMP写了,93ms,挺快的. 我又用AC自动机写了一遍,万万没想到竟然超时了. 后来看别人有用字符串hash写的,于是又用字符串hash写了一遍,代码30+行,而且速度也挺快…
题目链接:http://poj.org/problem?id=2121 差一点就WA哭了,主要是自己傻逼了. 思路: 遇到hundred,sum*100; 但是遇到thouthend,million,ans+=sum*(... ...),sum=0; 因为到了thouthend,million,后面肯定又是新的数字,跟前面的没关系了,sum=0; 而hundred,后面是可以再加数的,比如22,所以这里只要sum*=100; 注意: 这里经典的一招,杰哥教我的,要重置一下order,只需要ord…
一.Description Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram that shows how many times each letter (but not blanks, digi…
求一个最小矩阵,经过复制能够覆盖原矩阵(覆盖,不是填充,复制之后可以有多的) *解法:横着竖着kmp,求最大公倍数的做法是不对的,见http://blog.sina.com.cn/s/blog_69c3f0410100tyjl.html 正解如http://poj.org/showmessage?message_id=153316 求出每一行的可以重复的子串长度,所有行都可以的(公共的)那个最小的长度就是最终所求矩阵的宽 求出宽之后把剩下那些列砍掉,然后要求矩阵的高,把每行看作一个整体kmp即可…
#include <iostream> #include <string> #define MAXN 26 using namespace std; int _m[MAXN]; int main() { //freopen("acm.acm","r",stdin); ; string s; int i; int k; memset(_m,,sizeof(_m)); ; k < ; ++ k) { getline(cin,s); ; i…
题意:按样例那样模拟…… 解法:模拟…… 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<string> #include<string.h> #include<math.h> #include<limits.h> #include<time.h> #include<stdlib.h> #include<…
Vertical Histogram Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21223 Accepted: 10048 Description Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the inp…
//截取字符串 ch 的 st~en 这一段子串返回子串的首地址 //注意用完需要根据需要最后free()掉 char* substring(char* ch,int st,int en) { ; char* pch=ch; ); pch=pch+st; ;i<length;i++) subch[i]=*(pch++); subch[length]='\0'; return subch; } 字符串截取 POJ 3080 Blue Jeans 题意 : 给出 n 个包含 60 个字符的字符串,问…