HDU 12,157 The number theory of the XI festival

Source: Internet
Author: User

Tanabata FestivalTime limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d &%i64 U

Description

On the day of Tanabata, matchmaker came to the digital kingdom, and he put a sign on the city gate and said to the people of the digital kingdom, "Do you want to know who your other half is?" then follow the signs and find it!
People come to the notice before they want to know who is their other half. The notice is as follows:



The factor of the number n is all positive integers that are smaller than n and divisible by n, such as the factor of 12 having 1,2,3,4,6.
Do you want to know your other half?

Input

The first line of the input data is a number T (1<=t<=500000), which indicates the number of groups of test data. Then there is the T-group test data, each set of test data has only one number N (1<=n<=500000).

Output

For each set of test data, output a number that represents the other half of the input data N.

Sample Input

321020

Sample Output

1822


#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include < queue> #include <vector> #include <iomanip> #include <math.h>using namespace std; #define FIN     Freopen ("Input.txt", "R", stdin), #define INF     0x3f3f3f3f#define lson l,m,rt<<1#define rson    m+1,r, Rt<<1|1typedef Long Long LL; LL P[500005];int Main () {    //fin for    (int. i=2;i<=500000;i++) for        (int j=i;j<=500000;j+=i)            p[j]+= i;    LL n,t;    scanf ("%lld", &t);    while (t--)    {        scanf ("%lld", &n);        printf ("%lld\n", p[n]-n+1);}    }

  



HDU 12,157 The number theory of the XI festival

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.