Tanabata Festival
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) total submission (s): 37249 Accepted Submission (s): 11625
Problem Description Tanabata day, matchmaker came to the digital kingdom, he posted a sign on the city gate, and the people of the Digital Kingdom said: "You want to know who your other half is?" then follow the signs to find it! "people came to the notice before the Want to know who is the 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? The first line of 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, export a number that represents the other half of the input data N. Sample INPUT3 2 Sample OUTPUT1 8 AUTHORIGNATIUS.L source Hangzhou Electric ACM Provincial Training Team qualifying Match Recommendeddy | We have carefully selected several similar problems for you:1286 1406 1211 1214 1164
#include <cstdio>#include<cstring>Const intN =500001;intNum[n];voidInit () { for(inti =1; i < N; i++) Num[i]=1; for(inti =2; i < N; i++) for(intj = i+i; J < N; J + =i) num[j]+=i; }voidSieve () {//memset (num, 1, sizeof (num)); for(inti =2; i < N; i++) for(intj =2; I*j < N; J + +) Num[i*J] + =J;}intMain () {intT; //Sieve ();Init (); scanf ("%d", &T); while(t--){ intN; scanf ("%d", &N); if(n = =1) {printf ("0\n"); Continue; } printf ("%d\n", Num[n]); } return 0;}
hdoj1215--Tanabata Festival (mathematics)