# Some water questions in the school competition, water questions in the school Competition

Source: Internet
Author: User

Some water questions in the school competition, water questions in the school Competition

1236: xq and Crystal MineTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 313 Solved: 76
[Submit] [Status] [Web Board] Description

Xq once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n> 1) is an n struct * contains n matrix with a diamond inscribed into it.

You are given an odd integer n. you need to draw a crystal of size n. the diamond cells of the matrix shocould be represented by character "D ". all other cells of the matrix shocould be represented by character "*". look at the examples to understand what you need to draw.

Input

The only line contains an integer n (3 <= n <= 101; n is odd ).

Output

Output a crystal of size n.

Sample Input
`357`
Sample Output
`*D*DDD*D***D***DDD*DDDDD*DDD***D*****D*****DDD***DDDDD*DDDDDDD*DDDDD***DDD*****D***`
HINT

Source

Q

AC code:

`#include <cstdio>#include <cstring>#include <algorithm>using namespace std; char a; int main(){    int n;    while(scanf("%d", &n)!=EOF)    {        for(int i=0; i<n; i++)        {            for(int j=0; j<n; j++)            {                a[i][j] = '*';            }        }        for(int i=0; i<=n/2; i++)        {            for(int j=n/2-i; j<=n/2+i; j++)            {                a[i][j] = 'D';            }        }        for(int i=n/2; i<n; i++)        {            for(int j=n/2-(n-i-1); j<=n/2+(n-i-1); j++)            {                a[i][j] = 'D';            }        }        for(int i=0; i<n; i++)        {            for(int j=0; j<n; j++)            {                printf("%c", a[i][j]);            }            printf("\n");        }    }    return 0;} `

1246: xq problem Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 351 Solved: 119
[Submit] [Status] [Web Board] Description

Input

There are multiple groups of test data. You need to process the data to the end of the file (EOF ).
Each group of data contains a positive integer n (1 <=n <= 100 ). Test data are separated by line breaks.

Output

The sum of all the even numbers from 1 to n is output for each group of test data.

Sample Input
`13`
Sample Output
`02`
HINT

Source

Q

AC code:

`#include <cstdio>#include <cstring>#include <algorithm>using namespace std; int main(){    int n;    while(scanf("%d", &n)!=EOF)    {        int ans = 0;        for(int i=1; i<=n; i++)        {            if(i%2==0)ans+=i;        }        printf("%d\n", ans);    }    return 0;}`

1240: Text HolesTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 281 Solved: 94
[Submit] [Status] [Web Board] Description

Xq wrote some text on a piece of paper and now he wants to know how many holes are in the text. What is a hole? If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. for example letters "A", "D", "O", "P", "Q" "R ", divide the plane into two regions so we say these letters each have one hole. similarly, letter "B" has two holes and letters such as "C", "E", "F", "K" have no holes. we say that the number of holes in the text is equal to the total number of holes in the letters of the text. help Chef to determine how many holes are in the text.

Input

The first line contains a single integer T <= 40, the number of test cases. T test cases follow. the only line of each test case contains a non-empty text composed only of uppercase letters of English alphabet. the length of the text is less then 100. there are no any spaces in the input.

Output

For each test case, output a single line containing the number of holes in the corresponding text.

Sample Input
`2CODECHEFDRINKEATCODE`
Sample Output
`25`
HINT

Source

Q

AC code:

`#include <cstdio>#include <cstring>#include <algorithm>using namespace std; char a; int judge(char a){    if(a == 'A')return 1;    else if(a == 'D') return 1;    else if(a == 'O') return 1;    else if(a == 'P') return 1;    else if(a == 'Q') return 1;    else if(a == 'R') return 1;    else if(a == 'B') return 2;    else return 0;} int main(){    int T;    scanf("%d", &T);    while(T--)    {        scanf("%s", a);        int ans = 0, len = strlen(a);        for(int i=0; i<len; i++)        {            ans +=judge(a[i]);        }        printf("%d\n", ans);    }    return 0;}`

1241: Fibonacci number Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 590 Solved: 68
[Submit] [Status] [Web Board] Description

Xq has recently become infatuated with the Fibonacci series, because when n tends to be infinite, the ratio of the next item to the previous item is getting closer and closer to the Golden division of 0.618. But what makes xq unhappy is that the Fibonacci number is growing too fast, so that when n is large, the 32-bit integer or even 64-bit integer in the computer cannot represent this number. For this reason, xq has encountered this problem. xq wants to know whether the number of the K (0 <= K <= 10 ^ 10000) is an odd or even number, because K is too big, xq does not know how to solve this problem. Now xq wants you to solve this problem. The Fibonacci series is the following series: 0, 1, 2, 3, 5 ......, Its formula is F (n) = F (n-1) + F (n-2), (n> = 2), where F (0) = 0, F (1) = 1.

Input

The first line, T, indicates that there are 1 <= T <100 test samples.
In the next T row, each row has one data K (0 <= K <= 10 ^ 10000), which indicates the item to be determined.

Output

If the K-th item is an even number, the output is YES; otherwise, the output is NO.

Sample Input
`201`
Sample Output
`YESNO`
HINT

Source

Q

AC code:

`#include <cstdio>#include <cstring>#include <algorithm>using namespace std; char a; int main(){    int T;    scanf("%d", &T);    while(T--)    {        scanf("%s", a);        int m = 0, len = strlen(a);        for(int i=0; i<len; i++)        {            m += a[i]-'0';        }        if(m%3==0)printf("YES\n");        else printf("NO\n");    }    return 0;}`

1242: Tang xuecang's honeymoon sequel Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 288 Solved: 15
[Submit] [Status] [Web Board] Description

In October 1 this year, Tang xuecang went out on a tour with his girlfriend again! This time Tang took his girlfriend to the beautiful city of north China South-xinyang.
Tang xuecang, who accompanied his girlfriend in the Pedestrian Street shopping mall, was surprised to find that Xiaoqiang, a junior high school math teacher, is now switching to a snack bar. As a math teacher of Tang xuecang, Xiao Qiang wanted to know the current math level of Tang xuecang, so he gave Tang xuecang a difficult number theory problem, and said to Tang, "if you can solve this problem, I will treat you tonight! ".

Now we know two numbers, gcd and lcm. If Tang xuecang has two numbers, a and B (a <= B), the maximum common divisor is gcd, and the minimum common factor is lcm.

Input

The input contains multiple groups of samples!In each group, enter an integer T (T <120), followed by T rows. Each row has two numbers gcd and lcm (1 <= gcd <= lcm <2 ^ 31)

Output

Corresponding to the input in each line. If a B does not meet the condition, the output is "senior Tang is so smart !", Otherwise, a B is output (a and B are separated by spaces). If multiple groups of solutions exist, the output corresponds to the group with the smallest a value,For details about the output format, see the example.

Sample Input
`21 23 4`
Sample Output
`1 2senior Tang is so smart!`
HINT

Assume that you have obtained the GCD function (the maximum common number.

Evaluate the LCM (least public multiple) function as follows:

Int lcm (int a, int B ){

Return a/gcd (a, B) * B;

}

Not complete...

Source

Yin Hua

AC code:

`#include <cstdio>#include <cstring>#include <algorithm>using namespace std; int main(){    int gcd, lcm, T;    while(scanf("%d", &T)!=EOF)    {        while(T--)        {            scanf("%d %d", &gcd, &lcm);            if(gcd<=lcm && lcm%gcd==0)            printf("%d %d\n", gcd, lcm);            else printf("senior Tang is so smart!\n");        }    }    return 0;}`

Related Keywords:
Related Article

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.