HDU 2011 Polynomial summation

Source: Internet
Author: User

Polynomial summationTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 52871 Accepted Submission (s): 30814


problem Descriptionthe polynomial is described as follows:
1-1/2 + 1/3-1/4 + 1/5-1/6 + ...
Now ask you to find out the first n of the polynomial.  
InputThe input data consists of 2 lines, the first is a positive integer m (m<100), the number of test instances, the second row contains m positive integers, and for each integer (may be set to n,n<1000), the first n of the polynomial.  
Outputfor each test instance n, the number of the first n items of the output polynomial is required. The output of each test instance is one row, and the result retains 2 decimal places.  
Sample Input
21 2
 
Sample Output
1.000.50

Source
<span style= "FONT-SIZE:18PX;" >//2011 #include <stdio.h> #include <math.h>int n,m;double t;int main () {scanf ("%d", &n), while (n--) { Double sum=0;//note the position of sum assigned to the initial value, which should be scanf in the while loop ("%d", &m); for (double i=1;i<=m;i++) {T=pow ( -1,i+1) *1.00;sum+=1/i *t;} printf ("%.2lf\n", sum);} return 0;} </span>


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 2011 Polynomial summation

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.