Score matrix code language: c

Source: Internet
Author: User
ArticleDirectory
    • Score Matrix
Score Matrix time limit: 1000 ms memory limit: 10000 k total time limit: 3000 Ms

Description:

We define the following matrix:
1/1 1/2 1/3
1/2 1/1 1/2
1/3 1/2 1/1
The elements on the diagonal line of the matrix are always 1/1, and the denominator of the scores on both sides of the diagonal line increases one by one.
The sum of the requested matrices.

Input:

Given an integer n (n <50000) in each row, the matrix is N * n.

Output:

Output answer, retain 2 decimal places.

Input example:

1
2
3

Output example:

1.00
3.00
5.67

Tip:

 

Source:

Code:

View code

 1 # Include <stdio. h>
2 # Include <stdlib. h>
3 Int Main ()
4 { Int N;
5 Scanf ( " % D " , & N );
6 Float I;
7 Float Sum = N;
8 For (I = 2 ; I <= N; I ++)
9 {
10 Sum = sum + 1 /I * 2 * (N-I + 1 );
11 }
12 Printf ( " %. 2f \ n " , Sum );
13 Return 0 ;
14 }

Contact Us

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.