Returns the sum of the number of columns.

Source: Internet
Author: User
Tags square root

Problem description

The sequence is defined as follows:
The first item of the series is N, and the subsequent items are the square root of the previous item, and the sum of the first m items of the series is obtained. There are multiple groups of input data. Each group occupies one row and consists of two integers n (n <10000) and M (M <1000). The meanings of N and m are as described above. Output outputs the sum of the input data in each group. Each test instance occupies one row and requires two decimal places in precision. Sample input81 42 2 Sample output94.733.41 code:

# Include <stdio. h>
# Include <math. h>
Int main ()
{
Double n, m, T;
Int I;
While (scanf ("% lf", & N, & M )! = EOF)
{
Double S = 0;
For (I = 0; I <m; I ++)
{
S = S + N;
T = SQRT (N );
N = T;
}
Printf ("%. 2lf \ n", S );
}
Return 0;
}

 

 

 

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.