Lightoj 1245 Math problems, finding patterns

Source: Internet
Author: User

1. Lightoj 1245 Harmonic Number (II) math problem

2, Summary: Read the problem, very rigorous, but it is really disgusting

Test instructions: Beg n/1+n/2+....+n/n,n<=2^31.

#include <iostream>#include<cstring>#include<cmath>#include<queue>#include<algorithm>#include<cstdio>#defineMax (A, b) a>b?a:b#defineF (I,A,B) for (int i=a;i<=b;i++)#defineMes (A, b) memset (A,b,sizeof (a))#defineINF 0x3f3f3f3f#defineLL Long Longusing namespacestd;Const intn=10010, max=1000100; ll Har (ll N) {ll sum=0, sq=sqrt (n); F (i,1, SQ) {Sum=sum+ (n/i-n/(i+1)) *i+n/i;//Disgusting to fry    }    if(SQ==N/SQ) {//Notesum-=sq; }    returnsum;}intMain () {intT;    LL N; scanf ("%d",&t); F (CAS,1, T) {scanf ("%lld",&N); printf ("Case %d:%lld\n", Cas,har (n)); }    return 0;}
View Code

Lightoj 1245 Math problems, finding patterns

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.