-->
当前位置:首页 > 题库

PROGRAMMING:Identification of six schools

Luz5年前 (2021-05-10)题库342
There are many disciples of the six major sects in the Wulin: Shaolin, Wudang, Kunlun, Emei, Huashan and Kongtong. They need to be able to identify each other in order to avoid being passed off by evil people.
The leaders of the six sects (hereinafter referred to as "zhengpai") gathered together for half a year to design such an identification method:
Every decent disciple has an identity verification code and is familiar with the verification rules. When a decent disciple meets another person who claims to be a decent disciple, he asks the other person to report his ID. If the verification is correct, make a friend; If the verification fails, it means that the other party is a fake and starts a war immediately (of course, if you can't fight, you'll slip away...)
The verification code is as follows:
*It consists of 9 digits;
*The first number indicates the sect number. Shaolin sect, Wudang sect, Kunlun sect, Emei sect, Huashan sect and Kongtong sect use '0' -'5 'in turn;
*The next four digits are recorded as integers' a ', and the last four digits are recorded as integers' B'( If a and B are less than 4 digits, add '0' to the left.)
For example, ` 000100015 'means Shaolin sect, ` a' is ` 10 ', ` B' is ` 15 '`
The validation rules are as follows:
1. Find out all prime numbers P1, P2, P3,... Between integer 'a' and Integer 'B' (including a and b) (hint: A and B can be any number of '0-9999')
1. Calculate the sum of all the prime numbers' sum '(if there is no prime number between a and B, then' sum 'counts as' 0')
1. Find the remainder of sum divided by 6`
1. If the remainder R is the same as the first sect number, the verification is passed; otherwise, the verification is failed
For example, the verification code '000100015' can pass the verification, because the prime numbers between '10-15' are '11' and '13', and the sum of all digits is (1 + 1 + 1 + 3) ='6 '. The remainder of 6 divided by 6 is' 0', which is the same as the sect number '0'.
Now I'll give you some identification codes. Please verify them and judge whether they are decent disciples or villains.
###Input format:
The first line gives a positive integer 'n' that does not exceed '100';
Next 'n' line, each line gives a 9 - bit verification code
Tip: the first parameter of scanf() function in C language can read a decimal integer if it uses'% d '; it can read a 5-digit decimal integer if it uses'% 5D'. This tip may help you type in this question.
###Output format:
For each verification code, the verification result is given in one line
*If the verification is passed, give the school first, then the sum of the prime digits' sum ', with one space in the middle. The six schools use Pinyin in turn: ` Shaolin ', ` Wudang', ` Kunlun ', ` Emei', ` Huashan ', ` Kongtong';
*If the verification fails, the war will start. Output ` fighting`
###Input sample 1:
```in
three
000200022
two hundred and nineteen million four hundred and ninety-two thousand and twenty-one
two hundred and two million two hundred and thirty thousand six hundred and sixty-six
```
###Output sample 1:
```out
shaolin 0
Fighting!
kunlun 986
```
###Input sample 2:
```in
three
five hundred million three hundred and twenty thousand and fifty
four hundred million nine hundred thousand one hundred and five
five hundred million one hundred thousand and two
```
###Output sample 2:
```out
Fighting!
huashan 22
kongtong 17
```







answer:If there is no answer, please comment