Lightoj 1336 Sigma Function

Source: Internet
Author: User

Main topic:

Δ (n) represents the and of all the factors of n, given a number n, the number of x between [1,n], which satisfies δ (x) is the number of an even x.

Problem Solving Ideas:

Want to go, no train of thought, only feel and 2 this factor is related, see everyone has made, feel the topic should not be too difficult, so hit the mark looked, found only 2x,x2,2*x2 factor is not even, just to calculate out then subtract duplicate of OK:

2x/x2: Can be converted, and when X is even, the two repeats.

2X/2*X2: When x is odd, the two repeats.

So the final result is n minus the number of X2 and 2*x2.

Code:

1#include <cstdio>2#include <cstring>3#include <iostream>4#include <algorithm>5#include <cmath>6 using namespacestd;7 8 intMain ()9 {Ten     Long LongT, N, L =1; Onescanf ("%lld", &t); A      while(T--) -     { -scanf ("%lld", &n); the         Long LongT1, T2; -T1 = (Long Long) sqrt (n);//Number of x^2 -T2 = (Long Long) sqrt (n/2);//Number of 2*x^2 -printf ("Case %lld:%lld\n", l++, N-t1-T2); +     } -     return 0; +}

Lightoj 1336 Sigma Function

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.