【POJ 3371】 Flesch Reading Ease(模拟)
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2090 | Accepted: 613 |
Description
Flesch Reading Ease, a readability test named after its deviser Rudolf Flesch, is among most ubiquitously used readability tests, which are principally employed for assessment of the difficulty to understand a reading passage written in English. The Flesch Reading Ease score of a passage relies solely on three statistics, namely the total numbers of sentences, words and syllables, of the passage. Specifically, the score is defined by the following formula:
.
As can be inferred from the above formula, a passage with a high Flesch Reading Ease score tends to favor shorter sentences and words, which is in compliance with commonsense in spite of partial accuracy. (Think of, for instance, the word "television". Long as it may seem, it is indeed one of the first words that any individual who studies English learns.) A related Wikipedia entry on Flesch Reading Ease [1] suggests that passages scoring 90~100 are comprehensible for an average American 5th grader, and 8th and 9th graders possess the ability to follow passages with a score in the range of 60~70, whereas passages not exceeding 30 in the score are best suitable for college graduates. The text of this problem, all sections taken into account, scores roughly 50 as per the calculation of Google Documents.
Despite the simplicity in its ideas, several aspects of its definition remains vague for any real-world implementation of Flesch Reading Ease. For the sake of precision and uniformity, the following restrictions adapted from [2] are adopted for this problem, to which you are to write a solution that effectively computes the Flesch Reading Ease score of a given passage of English text.
Input
Output
Sample Input
Flesch Reading Ease, a readability test named after its deviser Rudolf Flesch, is among most ubiquitously used readability tests, which are principally employed for assessment of the difficulty to understand a reading passage written in English. The Flesch Reading Ease score of a passage relies solely on three statistics, namely the total numbers of sentences, words and syllables, of the passage.
Sample Output
26.09
Source
模拟= =好没意思的模拟……
求出给的段落里单词个数,句子个数还有元音个数。
给出了注意事项,
1.e、es、ed结尾的,e不计入元音,但le结尾除外
2.连续的元音算作一个
3.如果单词的字母数量小于等于3,不管有没有元音,整个单词算作一个元音
原本用getchar一点点判断来做得,结果不知道哪里出问题了,死活都是WA。
后来改成scanf(%s),把空格忽略掉,判断得到的串末尾标点。然后判断串长,小于等于3直接累计一个元音。否则一个个字母判断,然后照着题来就行,没坑点,getchar写法应该是我手残了,不过确实也不太好写,有兴趣的可以写写看,scanf19ms getchar应该能上0
代码如下:
#include <iostream> #include <cmath> #include <vector> #include <cstdlib> #include <cstdio> #include <cstring> #include <queue> #include <list> #include <algorithm> #include <map> #include <set> #define LL long long #define fread() freopen("in.in","r",stdin) #define fwrite() freopen("out.out","w",stdout) using namespace std; const int INF = 0x3f3f3f3f; const int msz = 10000; const double eps = 1e-8; //判断某字母是元音音节 bool issyl(char ch) { return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y'; } //判断某字符为字母 bool isal(char ch) { return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'); } int main() { freopen("in.in","r",stdin); char str[111]; int len; int sentences,words,syllables; sentences = words = syllables = 0; while(~scanf("%s",str)) { len = strlen(str)-1; //去掉后缀的标点 while(len >= 0 && !isal(str[len])) { //后缀标点不为',' 则为句子分隔符 if(str[len] != ',') sentences++; len--; } len++; words++; //单词长度小于等于3 if(len > 0 && len <= 3) { syllables++; } else if(len > 0) { for(int i = 0; i < len; ++i) { //字母为元音 if(issyl(str[i])) { //为连续的元音 if(i && issyl(str[i-1])) continue; //为e if(str[i] == 'e' || str[i] == 'E') { //为单词末尾 if(i == len-1) { //le结尾 if(i && (str[i-1] == 'l' || str[i-1] == 'L')) syllables++; } //为es或ed else if(i == len-2 && (str[i+1] == 's' || str[i+1] == 'd' || str[i+1] == 'S' || str[i+1] == 'D')){} else syllables++; } else syllables++; } } }else words--; } printf("%.2f\n",206.835-1.015*(words*1.0/sentences)-84.6*(syllables*1.0/words)); return 0; }