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 on the way to 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?
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 Input
321020
Sample Output
1822
The code is as follows:
#include <iostream> #include <cmath>using namespace Std;int main () { int t,n,i,sum; Double M; cin>>t; while (t--) { cin>>n; M=sqrt ((double) N); Optimization program sum=1; for (i=2; i<=m; i++) { if (n%i==0&&i*i!=n) sum+= (i+n/i); else if (n%i==0) sum+=i; } cout<<sum<<endl; } return 0;}
Problem Solving Ideas:
Simple but also deceptive, the topic requirements are easy to understand. The most critical step is to optimize the step, otherwise it will be time overrun, the visibility of how important optimization is,
Yt14-hdu-destined for the other half