# Stupid bear (Nanyang oj62) and bear Nanyang oj62

Source: Internet
Author: User

Stupid bear (Nanyang oj62) and bear Nanyang oj62
Stupid bear time limit: 2000 MS | memory limit: 65535 KB difficulty: 2

Description

Dummies have a small vocabulary, so they have a headache every time they make English choices. However, he found a method. The experiment proves that it is very likely to select the right option when using this method!
The specific description of this method is as follows: Suppose maxn is the number of occurrences of the most frequently-occurring letters in a word, and minn is the number of occurrences of the letters with the least number of occurrences in a word, if maxn-minn is a prime number, the stupid bear thinks it is a Lucky Word. Such words are probably the correct answer.

Input
The first row of data N (0 <N <100) indicates the number of test data groups.
Each group of test data has only one line of input, which is a word. Only lowercase letters may appear and the length is less than 100.
Output
Two rows are output for each group of test data. The first row is a string. If the input Word is Lucky Word, "Lucky Word" is output; otherwise, "No Answer" is output ";
The second line is an integer. If the input Word is Lucky Word, the value of maxn-minn is output; otherwise, 0 is output.
Sample Input
`2errorolympic`
Sample output
`Lucky Word2No Answer0`
`# Include <stdio. h> # include <string. h ># include <algorithm> using namespace std; int s [200] = {, 0}; int main () {// prime number table. Int I, j; for (I = 2; I * I <200; I ++) {if (! S [I]) {for (j = I + I; j <200; j + = I) {s [j] = 1 ;}} char a [200]; int B [200]; int len, k, max, min, test; scanf ("% d", & test); getchar (); while (test --) {memset (B, 0, sizeof (B); gets (a); len = strlen (a); for (I = 0; I <len; I ++) // count the number of occurrences of each character. {For (j = 0; j <len; j ++) {if (a [I] = a [j]) B [I] ++ ;}} max = min = B [0]; for (I = 0; I <len; I ++) // find the characters that appear most frequently and least. {If (B [I]> max) max = B [I]; if (B [I] <min) min = B [I];} k = max-min; if (! S [k]) {printf ("Lucky Word \ n"); printf ("% d \ n", k );} else {printf ("No Answer \ n"); printf ("0 \ n") ;}} return 0 ;}`

I think there is no problem with the program, but I cannot submit it. # include <stdioh>

What about your question description? The main function is a bit dizzy and you don't know what to do. Give the questions and test examples. It's meaningless to guess your logic.

If (! (Check % 2 ))
If (check! = 2) return 0;
Else return 1;

Whether
If (! (Check % 2 ))
{
If (check! = 2) return 0;
Else return 1;
}

Nanyang Institute of Technology acm stupid bear problem, I feel there is no problem with the program, but an error occurs when I submit

What programs are you using? Why are there so many cases?
Why not directly use B [a [I]-'a'] ++

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.