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