"Algorithmic Competition Primer Classic Second Edition" P35 exercise 2-4 sub-sequence and (subsequence)

Source: Internet
Author: User

/*"Algorithmic Competition Primer Classic Second Edition" P35 exercise 2-4; Enter two positive integers n < m < 10^6, output (1/n) ^2 + 1/(n+1) ^2 +......+ 1/m^2, retain 5 decimal places.  The input contains multiple sets of data, and the end flag is m=n=0. Wrong welcome to point out ^_^*/#include<stdio.h>intMain () {intm,n,i,j=1;  while(SCANF ("%d%d", &m,&n)! =EOF) {        Doublesum =0; if(m==0&& n==0)             return 0; Else        {             for(i=m; i<=n; i++) {sum+= ((1.0/i) * (1.0/i));//Fractional Arithmetic writes a numerator or denominator to a floating-point type, allowing it to automatically convert to decimals. } printf ("Case %d:%.5f\n", j,sum); J++; }    }    return 0;}

"Algorithmic Competition Primer Classic Second Edition" P35 exercise 2-4 sub-sequence and (subsequence)

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.