hdoj1215--Tanabata Festival (mathematics)

Source: Internet
Author: User

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)

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.